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

fix(server): use case-insensitive comparison for Expect: 100-continue #2709

Merged
merged 2 commits into from Nov 30, 2021
Merged

fix(server): use case-insensitive comparison for Expect: 100-continue #2709

merged 2 commits into from Nov 30, 2021

Conversation

JonathanMurray
Copy link
Contributor

According to rfc2616#section-14.20 the header value is case-
insensitive. Certain clients (including Java's std lib
https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/master/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java#L408)
send the expectation as 100-Continue and this should be handled
by the server.

(This is an attempt to address #2708)

@JonathanMurray JonathanMurray changed the title fix (server): use case-insensitive comparison for Expect: 100-continue fix(server): use case-insensitive comparison for Expect: 100-continue Nov 30, 2021
// According to https://datatracker.ietf.org/doc/html/rfc2616#section-14.20
// Comparison of expectation values is case-insensitive for unquoted tokens
// (including the 100-continue token)
expect_continue = value.to_str().map(|s| s.eq_ignore_ascii_case("100-continue")).unwrap_or(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eq_ignore_ascii_case should also available with .as_bytes()
See: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.eq_ignore_ascii_case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's great! Using that instead now.

Jonathan Murray added 2 commits November 30, 2021 14:59
According to rfc2616#section-14.20 the header value is case-
insensitive. Certain clients (including Java's std lib
https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/master/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java#L408)
send the expectation as `100-Continue` and this should be handled
by the server.

Closes: #2708
@seanmonstar seanmonstar merged commit 7435cc3 into hyperium:master Nov 30, 2021
@seanmonstar
Copy link
Member

Thank you!

@JonathanMurray JonathanMurray deleted the expect-100-continue-case-insensitive branch November 30, 2021 17:06
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 this pull request may close these issues.

None yet

3 participants