-
Notifications
You must be signed in to change notification settings - Fork 117
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
Refactor Request Validation #391
Refactor Request Validation #391
Conversation
6e1fa34
to
0d47360
Compare
struct RequestFramingMetadata { | ||
enum Body { | ||
struct RequestFramingMetadata: Equatable { | ||
enum Body: Equatable { |
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.
Make these Hashable
: Equatable
by itself is rarely sensible.
// This assert can go away when (if ever!) the above `if` correctly handles other HTTP versions. For example | ||
// in HTTP/1.0, we need to treat the absence of a 'connection: keep-alive' as a close too. | ||
assert(head.version == HTTPVersion(major: 1, minor: 1), | ||
"Sending a request in HTTP version \(head.version) which is unsupported by the above `if`") |
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.
I don't think this assert
is meaningfully enforcing here, is it? You (rightly) kept the original, but this one seems superfluous.
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, I still don't think this assertion is useful. We literally set the HTTP version to a hardcoded constant just above.
Co-authored-by: Cory Benfield <[email protected]>
6a6fd09
to
f9f1050
Compare
Motivation
Currently the request validation (mainly checking for correct headers is sprinkled around). This makes reuse in new code hard.
Changes
TaskHandler
into new methodHTTPClient.Request.createRequestHead
that creates anHTTPRequestHead
and matchingRequestFramingMetadata
requestFramingMetadata
toHTTPExecutingRequest
requestFramingMetadata
toRequestBag