Skip to content

Remove redundant RequestFramingMetadata.Body.none case #480

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

Merged
merged 2 commits into from
Nov 18, 2021

Conversation

dnadoba
Copy link
Collaborator

@dnadoba dnadoba commented Nov 18, 2021

Motivation

The distinction between no request body (.none) and a request body of size 0 (.fixedSize(0)) is unnecessary and we explicitly have code to ignore this:

case .fixedSize(let length) where length > 0:
self.state = .running(.streaming(expectedBodyLength: length, sentBodyBytes: 0, producer: .producing), .waitingForHead)
return .sendRequestHead(head, startBody: true)
case .none, .fixedSize:
// fallback if fixed size is 0
self.state = .running(.endSent, .waitingForHead)
return .sendRequestHead(head, startBody: false)

We can therefore just remove it.

Changes

  • replace .none with .fixedSize(0)
  • remove .none from the definition of RequestFramingMetadata.Body

Copy link
Member

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

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

Great improvement

@dnadoba dnadoba added the 🔨 semver/patch No public API change. label Nov 18, 2021
@dnadoba dnadoba merged commit 1f3f141 into swift-server:main Nov 18, 2021
@dnadoba dnadoba deleted the dn-remove-body-length-none branch December 7, 2021 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants