Replies: 1 comment
-
Sorry if I've misunderstood your question but retrieving the headers doesn't consume the response just borrows them? So what I usually do, whilst perhaps not optimal is just cloning them (or if I need to transform them, iterate over them mapping over the borowed name/value). E.g. let status = response.status();
let headers = response.headers().clone();
let body = response.text().await.expect("Failed to read response body"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear reqwest developers,
I am a Rust developer using your reqwest library and I have encountered an issue that I would like to seek your help and advice on.
In my project, I need to retrieve the HTTP response status code, headers, and body as bytes all at once. However, I have found that accessing the response headers from the
Response
object consumes the object, making it impossible to subsequently access the body bytes. This situation has posed a challenge for me, and I am hoping to find a way to address this issue.I am looking to fetch the complete response - status code, headers, and body bytes - within a single HTTP request. Is there a method that allows me to maintain the integrity of the
Response
object so that I can retrieve different parts of the response multiple times? Alternatively, do you have any other suggestions or best practices to achieve the desired outcome?I truly appreciate the excellent work you have put into developing the reqwest library, and I sincerely hope to receive your guidance and advice. I look forward to your response. Thank you very much!
Best regards,
bayegy
Beta Was this translation helpful? Give feedback.
All reactions