Comments (10)
I agree and it is possible! There is a similar ticket for Typhoeus:
typhoeus/typhoeus#247.
On Jul 13, 2013 9:21 PM, "Tasos Laskos" [email protected] wrote:
It would be nice if we could access the raw HTTP request data for later
inspection/auditing/debugging.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/63
.
from ethon.
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.
from ethon.
You are right!
On Jul 15, 2013 2:08 PM, "Tasos Laskos" [email protected] wrote:
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.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/63#issuecomment-20965416
.
from ethon.
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:
GET / HTTP/1.1
Host: www.example.com
Accept: */*
GET / HTTP/1.0
Host: example.iana.org
Accept: */*
In the proc, data
should be a pointer and size
should be a number, but for some reason the types are reversed. Here's the expected prototype:
int curl_debug_callback (CURL *, curl_infotype, char *, size_t, void *);
Source: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTDEBUGFUNCTION
from ethon.
To support always saving the raw request headers in ethon, a callback could be added to Ethon::Easy::Callbacks
using debugfunction
to grab the request headers, but the verbose
option would also need to be set to true.
Should this be the default behavior?
from ethon.
@linrock I think so.
from ethon.
@linrock do you want to take a stab at it? Your code works, should be a matter of putting it into the right place.
from ethon.
@i0rek Sure, I'll work on it.
from ethon.
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 rspec
without arguments, it hangs and eventually segfaults on the "when no follow location" test. Reproduced this on both mac and linux on ruby 2.0.0-p247. Not sure why this happens.
from ethon.
Thanks to @linrock this is now available in master via easy.debug_info
from ethon.
Related Issues (20)
- Stale sockets in CLOSE_WAIT state after b4899b952 HOT 2
- Memory leak in Ethon::Easy HOT 14
- Ruby 3.1.0-dev warning: Exception in finalizer
- Seg Fault on Ubuntu 20.04 Arm64 HOT 4
- JRuby failure with 0.15.0 - NoMethodError: undefined method `bitmask' HOT 1
- Crashes if first use is inside a fork (ex. spring) HOT 10
- Frozen at ETHON: Libcurl initialized HOT 3
- Segfault on autopointer.rb:175 HOT 4
- Can I use curl --resolve?
- Non-blocking IO support with Ruby 3.x fiber scheduler HOT 1
- Easy perform returns `url_malformat` for valid URLs HOT 1
- Custom libcurl.so
- 0.16.0 changelog HOT 1
- http2 example doesn't work: syntax error, unexpected local variable or method, expecting ')' multi.add(easy) HOT 1
- 0.16.0 broke a test in typhoeus
- Ruby-win64 support with libcurl-x64.dll HOT 3
- When Following Redirects `on_headers` Only Emits On First Response
- easy_codes mismatch at 60 HOT 2
- segmentation fault at operations.rb:30 HOT 1
- [BUG] Segmentation fault at ethon-0.16.0/lib/ethon/easy/operations.rb:30 HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ethon.