-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP::Client may set an output stream for debugging? #6335
Comments
Could you explain what it does? (apart from opening a serious security hole :-P) |
e, I'm a rubyist, and a fresher for Crystal. I wrote a gem, named 'http-proxy', I mirrored the code to github here: as write in README.md when I use >> r = TestModule.order_query(params) due the settings: http.set_debug_output(STDERR) if $VERBOSE in: the STDERR puts all the network details, such as http header strings, http response:
the set_debug_output method is defined in ruby core net/http: def set_debug_output(output)
warn 'Net::HTTP#set_debug_output called after HTTP started', uplevel: 1 if started?
@debug_output = output
en I search the code for crystal all over, but I can't found anything about how to puts the network logs when debugging. please help me, thank you. |
Yeah, it would be nice to have something like that built in in Crystal's http server. |
I wonder if it wouldn't even be nicer to just have an IO that forwards it to two other... oh wait https://crystal-lang.org/api/0.25.1/IO/MultiWriter.html So now we just need #1330 |
IO::MultiWriter is awesome, I'll try it later, thanks @jhass . |
@zfjoy520 He meant to use that in the HTTP::Client implementation in case debug output is enabled. I don't think you'll be able to do it without changing HTTP::Client's code. |
Well specifically I meant allowing the user to pass the socket or rather io to the client would allow this and more without as invasive changes. |
@icyleaf thanks. |
There's still a feature request here |
I added this to #6011 |
Since #9543 require "http"
http_connection = TCPSocket.new("crystal-lang.org", 80)
multi_writer = IO::MultiWriter.new(http_connection, STDOUT)
# stapling is necessary because MultiWriter does not support reads
stapled = IO::Stapled.new(http_connection, multi_writer)
client = HTTP::Client.new(stapled, "crystal-lang.org", 80)
puts client.get("/") Maybe this could be more enhanced, but I'd wait for the |
Hi,
May HTTP::Client somewhere to set the debug_output stream in verbose mode?
like pure ruby net/http in:
https://github.com/ruby/ruby/blob/51cfea31e559ce281f7252a2dd0117f61a44912e/lib/net/http.rb#L710
tks.
The text was updated successfully, but these errors were encountered: