jnunemaker / httparty

:tada: Makes http fun again!
MIT License
5.79k stars 968 forks source link

[debug_output]: Remove the section that reads bytes, or specify the length of bytes to display in the console!! #806

Open motebaya opened 1 month ago

motebaya commented 1 month ago

it looks like this is a duplicate of #715, but there’s been no response so far.

let say i have this code:

require 'httparty'
require_relative 'lib/Logging'

logger = Logging.new(progname: 'httparty', level: Logger::DEBUG)

HTTParty::Basement.debug_output(logger)
response = HTTParty.get('https://jsonplaceholder.typicode.com/todos/1')
puts response.body

Imagine calling a JSON that’s 100MB in size and having all its bytes displayed in the console! That would waste a lot of time handling I/O operations dude, and i'd have to scroll way up just to see the headers.

Screenshot 2024-08-09 200359

i hope there will be a feature added to disable byte display in the console or limit the length of bytes.

look at python; it handles this very well. i wish HTTParty could do the same.

Screenshot 2024-08-09 202456

motebaya commented 1 month ago

i know this is just a wrapper around the built-in Net::HTTP module, but HTTParty doesn’t handle the messy output in debug mode at all. it's ok, this might be able to fix it with creating custom logger: https://gist.github.com/motebaya/d3436ec35874a342e01da10170c85bca