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

Connection Header case insensitivity #635

Closed
mikedilger opened this issue Aug 27, 2015 · 2 comments
Closed

Connection Header case insensitivity #635

mikedilger opened this issue Aug 27, 2015 · 2 comments
Labels
A-headers Area: headers. C-bug Category: bug. Something is wrong. This is bad! E-easy Effort: easy. A task that would be a great starting point for a new contributor.

Comments

@mikedilger
Copy link
Contributor

http://tools.ietf.org/html/rfc7230#section-6.1:

... "Connection options are case-insensitive." ...

I noticed that Apache Bench sends "Keep-Alive" and hyper misinterprets it

DEBUG:hyper::server::request: Headers { Connection: Keep-Alive, Host: 192.168.66.62:8881, Accept: */*, User-Agent: ApacheBench/2.3, }
TRACE:hyper::http: should_keep_alive( Http10, Some(Connection([ConnectionHeader(UniCase("Keep-Alive"))])) )

I think this may also apply to most other headers

@seanmonstar
Copy link
Member

That's what the use of UniCase is for. However, I think the issue is in the parsing of the Connection header, in this case. Instead of being parsed as the KeepAlive variant, it's the ConnectionHeader variant.

@seanmonstar
Copy link
Member

Specifically, this method: https://github.com/hyperium/hyper/blob/master/src/header/common/connection.rs#L28

Instead, it should do a couple comparisons instead of a match.

if s == KEEP_ALIVE {
// ...
} else if s == CLOSE {
// ...
}

With the constants being UniCase("keep-alive") and UniCase("close").

@seanmonstar seanmonstar changed the title header case insensitivity Connection Header case insensitivity Aug 27, 2015
@seanmonstar seanmonstar added C-bug Category: bug. Something is wrong. This is bad! A-headers Area: headers. E-easy Effort: easy. A task that would be a great starting point for a new contributor. labels Aug 27, 2015
mikedilger added a commit to mikedilger/hyper that referenced this issue Aug 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-headers Area: headers. C-bug Category: bug. Something is wrong. This is bad! E-easy Effort: easy. A task that would be a great starting point for a new contributor.
Projects
None yet
Development

No branches or pull requests

2 participants