Verify payload-based stream channel fixes #214 (#228)

Motivation:

We made a bunch of changes to resolve #214. We should add a test to
ensure we actually fixed the issue.

Modifications:

- Add a test verifying that we can write on streams in a different order
  to the order in which we create them
- Add a corresponding test for frame-based streams verifying that the
  first write on each stream must match the order in which the streams
  were created
- Remove an unnecessary `throws` in the base HTTP2 to HTTP1 server codec

Result:

- No functionality change, just more tests.
This commit is contained in:
George Barnett authored and GitHub committed 2020-08-05 10:19:05 +01:00
1 parent 38afdfce3e
commit e9627350bd
8 files changed
+127 -19

No files matched your search

+6 -18
View File
@@ -274,7 +274,7 @@ fileprivate struct BaseServerCodec {
}
}
mutating func processOutboundData(_ data: HTTPServerResponsePart, allocator: ByteBufferAllocator) throws -> HTTP2Frame.FramePayload {
mutating func processOutboundData(_ data: HTTPServerResponsePart, allocator: ByteBufferAllocator) -> HTTP2Frame.FramePayload {
switch data {
case .head(let head):
let h1 = HTTPHeaders(responseHead: head)
@@ -350,15 +350,9 @@ public final class HTTP2ToHTTP1ServerCodec: ChannelInboundHandler, ChannelOutbou
public func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?) {
let responsePart = self.unwrapOutboundIn(data)
do {
let transformedPayload = try self.baseCodec.processOutboundData(responsePart, allocator: context.channel.allocator)
let part = HTTP2Frame(streamID: self.streamID, payload: transformedPayload)
context.write(self.wrapOutboundOut(part), promise: promise)
} catch {
promise?.fail(error)
context.fireErrorCaught(error)
}
let transformedPayload = self.baseCodec.processOutboundData(responsePart, allocator: context.channel.allocator)
let part = HTTP2Frame(streamID: self.streamID, payload: transformedPayload)
context.write(self.wrapOutboundOut(part), promise: promise)
}
}
@@ -409,14 +403,8 @@ public final class HTTP2FramePayloadToHTTP1ServerCodec: ChannelInboundHandler, C
public func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?) {
let responsePart = self.unwrapOutboundIn(data)
do {
let transformedPayload = try self.baseCodec.processOutboundData(responsePart, allocator: context.channel.allocator)
context.write(self.wrapOutboundOut(transformedPayload), promise: promise)
} catch {
promise?.fail(error)
context.fireErrorCaught(error)
}
let transformedPayload = self.baseCodec.processOutboundData(responsePart, allocator: context.channel.allocator)
context.write(self.wrapOutboundOut(transformedPayload), promise: promise)
}
}