Skip to content

Conversation

@fabianfett
Copy link
Member

Motivation

Currently the request validation (mainly checking for correct headers is sprinkled around). This makes reuse in new code hard.

Changes

  • Refactored code from TaskHandler into new method HTTPClient.Request.createRequestHead that creates an HTTPRequestHead and matching RequestFramingMetadata
  • Added required property requestFramingMetadata to HTTPExecutingRequest
  • Added property requestFramingMetadata to RequestBag

@fabianfettfabianfett added the 🔨 semver/patch No public API change. label Jul 7, 2021
@fabianfettfabianfettforce-pushed the ff-refactor-request-validation branch from 6e1fa34 to 0d47360CompareJuly 7, 2021 13:01
structRequestFramingMetadata{
enumBody{
structRequestFramingMetadata:Equatable{
enumBody:Equatable{
Copy link
Collaborator

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`")
Copy link
Collaborator

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.

Copy link
Collaborator

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.

@fabianfettfabianfett added this to the HTTP/2 support milestone Jul 7, 2021
@fabianfettfabianfettforce-pushed the ff-refactor-request-validation branch from 6a6fd09 to f9f1050CompareJuly 7, 2021 17:02
@fabianfettfabianfett merged commit bccb075 into swift-server:mainJul 7, 2021
@fabianfettfabianfett deleted the ff-refactor-request-validation branch July 7, 2021 17:50
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patchNo public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@fabianfett@Lukasa