curl-rust
curl-rust copied to clipboard
more easily get access to headers in Easy2 client
In the Easy struct there is a header_function (https://docs.rs/curl/0.4.44/curl/easy/struct.Easy.html#method.header_function) that allows one to get access to all headers. This option is however not available to Easy2.
Would it be possible to expose this somehow? as currently I need to use something very hacky. I use show_headers and parse it myself from the body... Which feels like a pretty wrong approach of having to do stuff and currently only works because I am focussing on a fairly easy HTTP/1.1 usage.
When using Easy2, you are meant to access incoming response headers by implementing the header method on your Handler. Under the hood, Easy::header_function gets the header data using this mechanism (since Easy is implemented on top of Easy2).
Note that both of these methods are streaming -- you don't call them to get the headers, but rather libcurl calls you with the headers as they are received in real time.
Awesome, that’s exactly what I need. There are even some more functions in there that help me out. Thanks!!! Perfect.