-
Notifications
You must be signed in to change notification settings - Fork 120
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
Verify header field names #191
Verify header field names #191
Conversation
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.
Awesome, thank you!
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.
One minor note
// | ||
// The presence of a message-body in a request is signaled by the inclusion of a | ||
// Content-Length or Transfer-Encoding header field in the request's message-headers. | ||
return |
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.
RFC 2616 is dead, let's stop citing it. It's RFC 7230 section 3.3. However, this change is not cautious enough: if there's no body, but the request verb is POST
, "Content-Length: 0" is mandatory. Content-Length: 0 is also harmless on all request types that do not define a body. A patch that users this escape hatch on only GET
, HEAD
, DELETE
, CONNECT
, and TRACE
would be acceptable though, so long as it sends C-L 0 everywhere else.
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.
Love it. If we fix up the compile errors this should be good to go.
@Lukasa Compile errors are fixed. There are some failing tests though (nothing I touched). |
@fabianfett it seems that most tests fail due to change in behaviour, |
@artemredkin ow shoot. fixed. |
awesome, thanks! there is one failing test, but this one is flaky (#175), I'll try to run tests again |
@swift-server-bot test this please |
@fabianfett From what I can tell, we're good but would you mind checking if we have a test case which covers this #146 ? If yes, we're all good, if no we might want to add it here? |
@swift-server-bot test this please |
thank you @fabianfett ! |
This pr builds on top of #189 and will need a rebase once the former is merged.
Motivation
Having spent about four hours today debugging AsyncHTTPClient just to find out I had a whitespace instead of a dash in my http header field name, I decided I want to save somebody else's time – probably future me.
User Agent
vsUser-Agent
Changes
HTTPHeaders.validateFieldNames() throws
.invalidHeaderFieldNames([String])
Result
Hours of time saved. Karma for me.