Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix exception when parsing HTTP/2 status line#15203

Merged
stephentoub merged 2 commits into
dotnet:masterfrom
yaakov-h:http2
Jan 18, 2017
Merged

Fix exception when parsing HTTP/2 status line#15203
stephentoub merged 2 commits into
dotnet:masterfrom
yaakov-h:http2

Conversation

@yaakov-h
Copy link
Copy Markdown
Member

Related issue: #14715

It appears that CurlResponseHeaderReader and it's tests always assume that the HTTP status line starts with a string HTTP/x.y where x and y are the HTTP major and minor version numbers, respectively.

For HTTP 2, the status line is HTTP/2 followed by a space and then the rest of the line. There is no . character to delimit between major and minor versions.

I believe this PR should be OK to merge unless you strictly require a unit test. In this area, I'm unsure as to how to modify CurlResponseParseUtilsTest and the MemberData provided to the test in order to create new test cases for HTTP/2 for all tests. Can I get a hand with including HTTP/2 unit tests?

Thanks.

@karelz
Copy link
Copy Markdown
Member

karelz commented Jan 17, 2017

cc @justinvp who wrote the original tests ;)

@justinvp
Copy link
Copy Markdown
Contributor

justinvp commented Jan 17, 2017

who wrote the original tests ;)

I believe the tests were originally written by @kapilash (I just moved/tweaked them at some point).

@Priya91
Copy link
Copy Markdown
Contributor

Priya91 commented Jan 17, 2017

For HTTP 2, the status line is HTTP/2 followed by a space and then the rest of the line. There is no . character to delimit between major and minor versions.

Is this a valid syntax for http protocol? In the RFC 7230 the protocol describes the syntax should be,

HTTP-version  = HTTP-name "/" DIGIT "." DIGIT

@yaakov-h
Copy link
Copy Markdown
Member Author

yaakov-h commented Jan 17, 2017 via email

Copy link
Copy Markdown
Contributor

@Priya91 Priya91 left a comment

Choose a reason for hiding this comment

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

I believe this PR should be OK to merge unless you strictly require a unit test. In this area, I'm unsure as to how to modify CurlResponseParseUtilsTest and the MemberData provided to the test in order to create new test cases for HTTP/2 for all tests. Can I get a hand with including HTTP/2 unit tests?

You can add the test by having a new StatusCodeMajorVersionOnlyFormat = HTTP/{0} 200 OK", and create memberdata for this format, through a method that generates major version from 1 to 10, and then write a new test like ReadStatusLine_ValidStatusCodeLine_ResponseMessageVersionSet test method with only major number.

Extend existing tests to cover status line with major version only.

HttpResponseMessage.Version should still have a value of (2, 0) to ensure
compatibility with Windows (see HttpVersionInternal) and full .NET
Framework, not a value of just (2).
Copy link
Copy Markdown
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the improvement and the tests to go with it.

@stephentoub
Copy link
Copy Markdown
Member

@dotnet-bot test outerloop Ubuntu14.04 Debug please
@dotnet-bot test outerloop OSX Debug please

@stephentoub stephentoub merged commit 8ddccab into dotnet:master Jan 18, 2017
@karelz
Copy link
Copy Markdown
Member

karelz commented Jan 18, 2017

+1 on thanks for the improvement!

@yaakov-h yaakov-h deleted the http2 branch January 18, 2017 20:26
@yaakov-h
Copy link
Copy Markdown
Member Author

Thanks, everyone!

@karelz karelz modified the milestone: 2.0.0 Jan 21, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Fix exception when parsing HTTP/2 status line.
* Extend curl tests to cover "HTTP/2" status line

Extend existing tests to cover status line with major version only.

HttpResponseMessage.Version should still have a value of (2, 0) to ensure
compatibility with Windows (see HttpVersionInternal) and full .NET
Framework, not a value of just (2).


Commit migrated from dotnet/corefx@8ddccab
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net.Http os-linux Linux OS (any supported distro)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants