Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
pkg/
*.gem
coverage/
spec/log/*.log
spec/log/*.log
gemfiles/*.lock
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ rvm:
- "2.2.8"
- "2.3.5"
- "2.4.2"
gemfile:
- gemfiles/http2.gemfile
- gemfiles/http3.gemfile
- gemfiles/http4.gemfile
# uncomment this line if your project needs to run something other than `rake`:
script: bundle exec rspec spec
# workaround for https://github.com/travis-ci/travis-ci/issues/5239:
Expand Down
5 changes: 5 additions & 0 deletions gemfiles/http2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "http", "~> 2.0"

gemspec path: ".."
5 changes: 5 additions & 0 deletions gemfiles/http3.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "http", "~> 3.0"

gemspec path: ".."
5 changes: 5 additions & 0 deletions gemfiles/http4.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "http", github: "httprb/http"

gemspec path: ".."
10 changes: 9 additions & 1 deletion lib/httplog/adapters/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ class Client
if log_enabled
HttpLog.log_request(req.verb, req.uri)
HttpLog.log_headers(req.headers.to_h)
HttpLog.log_data(req.body) #if req.verb == :post

if defined?(::HTTP::Request::Body)
body = req.body.respond_to?(:source) ? req.body.source : req.body.instance_variable_get(:@body)
else
body = req.body
end

HttpLog.log_data(body.to_s)
body.rewind if body.respond_to?(:rewind)
end

bm = Benchmark.realtime do
Expand Down