-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Correctly handle repeated headers. #743
Conversation
Thanks for contributing! Unfortunately, I'm here to tell you there were the following style issues with your Pull Request:
Guidelines are available at https://github.com/hyperium/hyper/blob/master/CONTRIBUTING.md This message was auto-generated by https://gitcop.com |
2ba4227
to
ca8958f
Compare
@@ -79,7 +79,6 @@ __hyper__tm!(ContentLength, tests { | |||
test_header!(test1, vec![b"3495"], Some(HeaderField(3495))); | |||
|
|||
test_header!(test_invalid, vec![b"34v95"], None); | |||
test_header!(test_duplicates, vec![b"5", b"5"], Some(HeaderField(5))); | |||
test_header!(test_duplicates_vary, vec![b"5", b"6", b"5"], None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you test this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the test_duplicates
test, from RFC7230#3.3.2:
If a message is received that has multiple Content-Length header
fields with field-values consisting of the same decimal value, or a
single Content-Length header field with a field value containing a
list of identical decimal values (e.g., "Content-Length: 42, 42"),
indicating that duplicate Content-Length header fields have been
generated or combined by an upstream message processor, then the
recipient MUST either reject the message as invalid or replace the
duplicated field-values with a single valid Content-Length field
containing that decimal value prior to determining the message body
length or forwarding the message.
For the test_duplicates_vary
test, step 4 of RFC7230#3.3.3:
If a message is received without Transfer-Encoding and with
either multiple Content-Length header fields having differing
field-values or a single Content-Length header field having an
invalid value, then the message framing is invalid and the
recipient MUST treat it as an unrecoverable error.
The request should error out with varying Content-Lengths, which hyper doesn't do, but at the very least, it shouldn't pick any of the stated values as valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this change never picks any of the stated values even if they are all identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the parsing of ContentLength
has been left alone, so this test should still pass. I'd rather keep the functionality of ContentLength
the same for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, my diagnosis was wrong (guessing is bad). This change doesn't change the behavior of ContentLength
as you say. However, it changes the behavior of the test_header
macro to correctly verify that parsing and then formatting a header returns the original header. However, in this case, hyper will "clean" the header removing the second content length so this test will fail.
ca8958f
to
9d39576
Compare
This looks fantastic. If you could add the |
HeaderX: a HeaderX: b MUST be interpreted as HeaderX: a, b See: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 Fixes hyperium#683
9d39576
to
70c6914
Compare
Thanks! |
HeaderX: a
HeaderX: b
MUST be interpreted as
See: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
Fixes #683