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
Only forward bytes on removal when we know we can handle it #430
Conversation
@normanmaurer doesn't compile, probably forgot to record something |
62a6e5e
to
37cc0c1
Compare
@weissi lol yeah... stupid me :( PTAL again |
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.
works for me, thanks! @Lukasa might want an enum instead of the bool though ;)
@Lukasa if you prefer an enum please let me know and also suggest a name ;) |
Sources/NIOHTTP1/HTTPDecoder.swift
Outdated
/// - 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) { |
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.
Let's have an enum
.
enum RemoveAfterUpgradeStrategy {
case forwardBytes
case dropBytes
}
37cc0c1
to
0b13de6
Compare
@Lukasa PTAL again... using an enum now. |
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 change, then I'm happy.
Sources/NIOHTTP1/HTTPDecoder.swift
Outdated
@@ -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. |
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.
Nit: let's write this as "Strategy to use when a HTTPDecoder
is removed from a pipeline after a HTTP upgrade was detected".
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.
addressed... will merge once green if I not hear back :)
0b13de6
to
6a34899
Compare
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.
fab0a12
to
b88ce7f
Compare
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.
yay
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:
Result:
Less risky implementation.