-
Notifications
You must be signed in to change notification settings - Fork 13
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
raw output (to String or ...) #15
Comments
i dont know about this is or not a feature, but for now you can add a patch to your code: class Halite::Response
def print_debug
puts "#{version} #{status_code} #{status_message}"
headers.each do |k, v|
puts "#{k}: #{v.join(", ")}"
end
puts
puts self
end
end
url = "https://httpbin.org/get"
r = Halite.get(url)
r.print_debug output:
|
Or write your custom logger and enable in each request. |
Wow, you are very fast providing this, thank you 👍 Firstly, the output seems as expected, but this way its morely a cosmetic output to see this like raw. This is because of your
because sometimes it´s very needed to know whats exactly comes in (or back) :-) The custom logger would do the same as it did not catch the original response? Thank you very much - it´s already a very good starting point :-) |
Let's improve the code 😄 class Halite::Response
def dump
String.build do |io|
io << version << " " << status_code << " " << status_message << "\n"
headers.each do |k, v|
io << k << ": " << v.join(", ") << "\n"
end
io << "\n"
io << to_s
end.to_s
end
end
url = "https://httpbin.org/get"
r = Halite.get(url)
puts r.dump Is it you want? |
I do not dare to answer :) ...no... because it´s adding manually But i did not dive deep enough into your source; maybe possible that getting this is not possible if Crystals stdlib always returns already parsed strings. Maybe you got always Strings from their methods and this is the rawest of raw :) If the last one is correct, than you have already saved me a lot of time because i can reduce doing things in the browser to a minimum - thats really awesome 👍 💯 |
You are right. all crystal give api is wrapped and it will auto Compression and encoding, check it: https://crystal-lang.org/api/0.25.0/HTTP/Client.html |
BTW, Crystal also give a method to returns raw by splice but Halite not delegate it: https://github.com/crystal-lang/crystal/blob/master/src/http/client/response.cr#L63 |
Wow - thanks! Ok, so - i am already very happy with your help and Halite - both were awesome for saving time 🥇 What do you think about merging above to your master? I think, Let's go with Halite :) |
Done, use |
Are you funny to implement that the complete response (with headers, 200 OK, ... etc.) is completely copyied to a
String
? I would need this to read all the bytes my server sends, like cookies too and output it myself withp
,pp
or simplyputs
:)I mean, actually we got this via
puts
:and i need this:
prefered as
String
:)This were nice 👍
The text was updated successfully, but these errors were encountered: