mirror of
https://github.com/apple/swift-nio
synced 2026-11-29 05:24:21 +00:00
Only forward bytes on removal when we know we can handle it (#430)
Motivation:
398b950eee 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.
This commit is contained in:
1 parent
9e0eb8347a
commit
d53ee6dafc
5 files changed
+104
-10
No files matched your search
@@ -140,15 +140,15 @@ public class HTTPServerUpgradeHandler: ChannelInboundHandler {
|
||||
|
||||
if let upgrade = self.upgrade {
|
||||
switch requestPart {
|
||||
case .head(_):
|
||||
case .head:
|
||||
ctx.fireErrorCaught(HTTPUpgradeErrors.invalidHTTPOrdering)
|
||||
notUpgrading(ctx: ctx, data: data)
|
||||
return
|
||||
case .body(_):
|
||||
case .body:
|
||||
// TODO: In the future way may want to add some API to also allow special handling of the body during the
|
||||
// upgrade. For now just ignore it.
|
||||
break
|
||||
case .end(_):
|
||||
case .end:
|
||||
self.seenFirstRequest = true
|
||||
|
||||
// The request is complete now trigger the upgrade.
|
||||
|
||||
Reference in new issue
Block a user