Comments (6)
I did stumble on that on one personal project (and hopefully, we weren't affected at work due to binary only responses).
I was going to make a PR for that this morning.
The culprit is the new added .dup
in HttpLog#log_body
:
data = parse_body(body.dup, mask_body, encoding, content_type)
With that, you have two instances of HTTP::Response::Body
. The first one to be "read" (by using to_s
) will consume the response from the connection. The other to be read will get nothing.
If the content type is "loggable", the instance in httplog is read and the instance you get is empty. If binary (hence not "loggable"), that's the response you get.
A proper way is:
- not dup here, but in parsse_body if needed
- call to_s explicitly before that instead of relying on the implicit to_s of the string interpolation.
from httplog.
Thanks, @maximeg
Curious when this fix will be released?
from httplog.
Well that's not good... :) Checking now
from httplog.
Well, it works fine with ruby 2.6.5 for me. With this setup:
# Gemfile
source 'https://rubygems.org'
ruby '2.6.5'
gem 'http'
gem 'httplog', '1.4.0'
# test.rb
require 'http'
require 'httplog'
puts HTTP.get('http://example.com').body.to_s
running bundle exec test.rb
logs the request and spits out the content of example.com. Checking ruby 2.7 now...
from httplog.
Works the same for me with ruby 2.7.0. http gem version is 4.3.0 - which one do you have? And can you provide a minimum example that reproduces the issue?
from httplog.
I am using gem 'http', '4.3.0'
from httplog.
Related Issues (20)
- Is it possible to check programmatically if any external HTTP requests were made after a run? HOT 1
- Exception `Errno::ESPIPE` with chunked transfer encoding and pipe-io as body HOT 1
- Need to require Json even if config.json_log = false
- Crash on frozen string during force_encoding HOT 2
- How to stop logging a PNG binary
- Dependency Dashboard
- Binary body logged HOT 1
- Is adding require 'httplog' necessary? HOT 1
- NoMethodError (undefined method `log' for nil:NilClass)
- No logs and `undefined method [] for nil:NilClass`, Rails 7 HOT 7
- Version 1.6 Changelog Documentation HOT 2
- Allow/block the logging on runtime HOT 3
- Allow regexp on params filter HOT 2
- '(not showing binary data)' when the content-type is text/html HOT 1
- config.severity doesn't change log level HOT 2
- Bug: Ethon adapter fails when response headers are empty HOT 2
- question: is blacklisting supposed to prevent the request from being sent? HOT 2
- Support for production? HOT 1
- Action Required: Fix Renovate Configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httplog.