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

HTTP headers wrongly treated as case-sensitive by client #39

Closed
AlyoshaVasilieva opened this issue Jan 19, 2022 · 4 comments · Fixed by #40
Closed

HTTP headers wrongly treated as case-sensitive by client #39

AlyoshaVasilieva opened this issue Jan 19, 2022 · 4 comments · Fixed by #40

Comments

@AlyoshaVasilieva
Copy link
Contributor

EspHttpResponse defines headers as BTreeMap<String, String>:

pub struct EspHttpResponse<'a> {
client: &'a mut EspHttpClient,
headers: BTreeMap<String, String>,
}

If a server sends Content-Type: something, then resp.content_type() returns None because embedded_svc asks for content-type and EspHttpResponse does a case-sensitive search:

self.headers
.get(name.as_ref())
.map(|s| Cow::Borrowed(s.as_str()))

I think the fix is replacing the String key with something like Uncased

@ivmarkov
Copy link
Collaborator

Uncased seems to cover our use case perfectly. Are you up for a PR?

@AlyoshaVasilieva
Copy link
Contributor Author

I'll try to work on it within the next day or two

@sehraf
Copy link

sehraf commented Jan 20, 2022

What is the advantage of uncased over something simple like to_lowercase()?

@AlyoshaVasilieva
Copy link
Contributor Author

Uncased doesn't require any additional allocations or modification of strings

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

Successfully merging a pull request may close this issue.

3 participants