-
Notifications
You must be signed in to change notification settings - Fork 139
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
Provide access to raw request data #63
Comments
I agree and it is possible! There is a similar ticket for Typhoeus:
|
Yeah I was hoping to access this via Typhoeus too but I figured it was up to Ethon to provide that access so I opened the ticket here. |
You are right!
|
Here's an example snippet that prints out the raw request headers using CURLOPT_DEBUGFUNCTION. callback = proc do |handle, type, data, size|
if type == 2 # CURLINFO_HEADER_OUT
data = FFI::Pointer.new(data) unless data.is_a? FFI::Pointer
request_headers = data.read_string_length size.to_i
puts request_headers
end
end
easy = Ethon::Easy.new url: "www.example.com",
followlocation: true,
verbose: true,
debugfunction: callback
easy.perform Prints out:
In the proc, int curl_debug_callback (CURL *, curl_infotype, char *, size_t, void *); Source: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTDEBUGFUNCTION |
To support always saving the raw request headers in ethon, a callback could be added to Should this be the default behavior? |
@linrock I think so. |
@linrock do you want to take a stab at it? Your code works, should be a matter of putting it into the right place. |
@i0rek Sure, I'll work on it. |
Please take a look! I'll updated as needed. After this set of changes, I did run into an issue with running the specs, where if I run them individually, they all work fine, but if I run them all at once via |
Thanks to @linrock this is now available in master via |
It would be nice if we could access the raw HTTP request data for later inspection/auditing/debugging.
The text was updated successfully, but these errors were encountered: