We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello,
I'm working on an API code generator. I want all the generated functions to return an access to all the headers and the parsed body.
To return all the headers I currently loop over response.headers_names() and then read the response.header(&name) :
response.headers_names()
response.header(&name)
pub(crate) fn get_header_map(response: &ureq::Response) -> HashMap<String, String> { let mut headers = HashMap::new(); let names = response.headers_names(); for name in names { if let Some(value) = response.header(&name) { headers.insert(name, value.to_string()); } } headers }
I find it very inefficient, the most efficient way from my point of view would be to add an access to the headers in the Response struct.
headers
Response
Do you think this would cause problems ? I can try to open a PR adding this function.
Edit: I found the "http-interop" feature, this could give me the access I want but I don't like the fact that unwrap() is called on into_string().
unwrap()
into_string()
The text was updated successfully, but these errors were encountered:
I got same problem.
But I prefer get_headers() -> &[Header], this is how it was stored in response after all. Then we can do other things on &[Header]
get_headers() -> &[Header]
&[Header]
Sorry, something went wrong.
Closing since we're moving to ureq 3.x. This is solved in ureq 3.x
Successfully merging a pull request may close this issue.
Hello,
I'm working on an API code generator.
I want all the generated functions to return an access to all the headers and the parsed body.
To return all the headers I currently loop over
response.headers_names()
and then read theresponse.header(&name)
:I find it very inefficient, the most efficient way from my point of view would be to add an access to the
headers
in theResponse
struct.Do you think this would cause problems ? I can try to open a PR adding this function.
Edit: I found the "http-interop" feature, this could give me the access I want but I don't like the fact that
unwrap()
is called oninto_string()
.The text was updated successfully, but these errors were encountered: