Skip to content
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

more easily get access to headers in Easy2 client #544

Open
GlenDC opened this issue Jan 27, 2024 · 2 comments
Open

more easily get access to headers in Easy2 client #544

GlenDC opened this issue Jan 27, 2024 · 2 comments

Comments

@GlenDC
Copy link

GlenDC commented Jan 27, 2024

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.

@sagebind
Copy link
Collaborator

sagebind commented Jan 27, 2024

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.

@GlenDC
Copy link
Author

GlenDC commented Jan 28, 2024

Awesome, that’s exactly what I need. There are even some more functions in there that help me out. Thanks!!! Perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants