Giter Site home page Giter Site logo

Comments (6)

maximeg avatar maximeg commented on August 19, 2024 2

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.

kapso avatar kapso commented on August 19, 2024 1

Thanks, @maximeg

Curious when this fix will be released?

from httplog.

trusche avatar trusche commented on August 19, 2024

Well that's not good... :) Checking now

from httplog.

trusche avatar trusche commented on August 19, 2024

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.

trusche avatar trusche commented on August 19, 2024

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.

kapso avatar kapso commented on August 19, 2024

I am using gem 'http', '4.3.0'

from httplog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.