Skip to content
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

Only forward bytes on removal when we know we can handle it #430

Merged

Conversation

normanmaurer
Copy link
Member

Motivation:

398b950 introduced a change which forwarded bytes that were buffered in HTTPDecoder after it was removed when an upgrade was detected. This may be risky if we dont know that the pipeline can handle it.

Modifications:

  • Add new initializer that allow us to configure if we should forward bytes or not.
  • Automatically use this if we know that we added an upgrader
  • Add unit tests.

Result:

Less risky implementation.

@weissi
Copy link
Member

weissi commented May 23, 2018

@normanmaurer doesn't compile, probably forgot to record something

@normanmaurer normanmaurer force-pushed the forward_bytes_only_if_configured branch from 62a6e5e to 37cc0c1 Compare May 23, 2018 14:06
@normanmaurer
Copy link
Member Author

@weissi lol yeah... stupid me :( PTAL again

Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

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

works for me, thanks! @Lukasa might want an enum instead of the bool though ;)

@normanmaurer
Copy link
Member Author

@Lukasa if you prefer an enum please let me know and also suggest a name ;)

/// - parameters:
/// - forwardAfterUpgrade: if `true` any remaining bytes that are currently buffered by the `HTTPRequestDecoder` will be forwarded
/// to the next handler in the pipeline once this decoder is removed from the pipeline and an upgrade was detected.
public convenience init(forwardAfterUpgrade: Bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's have an enum.

enum RemoveAfterUpgradeStrategy {
    case forwardBytes
    case dropBytes
}

@normanmaurer normanmaurer force-pushed the forward_bytes_only_if_configured branch from 37cc0c1 to 0b13de6 Compare May 23, 2018 15:52
@normanmaurer
Copy link
Member Author

@Lukasa PTAL again... using an enum now.

Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

One minor change, then I'm happy.

@@ -187,6 +195,14 @@ public final class HTTPResponseDecoder: HTTPDecoder<HTTPClientResponsePart>, Cha
}
}

/// Strategy to use when a decoder is removed from the pipeline and an HTTP upgrade was detected before.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: let's write this as "Strategy to use when a HTTPDecoder is removed from a pipeline after a HTTP upgrade was detected".

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed... will merge once green if I not hear back :)

@normanmaurer normanmaurer force-pushed the forward_bytes_only_if_configured branch from 0b13de6 to 6a34899 Compare May 23, 2018 16:55
@Lukasa Lukasa added the 🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0 label May 23, 2018
@Lukasa Lukasa added this to the 1.8.0 milestone May 23, 2018
Motivation:

398b950 introduced a change which forwarded bytes that were buffered in HTTPDecoder after it was removed when an upgrade was detected. This may be risky if we dont know that the pipeline can handle it.

Modifications:

- Add new initializer that allow us to configure if we should forward bytes or not.
- Automatically use this if we know that we added an upgrader
- Add unit tests.

Result:

Less risky implementation.
@normanmaurer normanmaurer force-pushed the forward_bytes_only_if_configured branch from fab0a12 to b88ce7f Compare May 23, 2018 17:10
Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

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

yay

@weissi weissi added patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) and removed 🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0 labels May 23, 2018
@normanmaurer normanmaurer merged commit d53ee6d into apple:master May 23, 2018
@normanmaurer normanmaurer deleted the forward_bytes_only_if_configured branch May 23, 2018 18:26
@normanmaurer normanmaurer modified the milestones: 1.8.0, 1.7.2 May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants