Remove ByteBufferAllocator constructor argument from HttpResponseEncoder

Motivation:

We can allocate the buffer on the fly if needed, no need to add the constructor argument.

Modifications:

Just allocate the buffer in the methods itself that need it.

Result:

Easier to construct encoder and cleaner code.
This commit is contained in:
Norman Maurer committed 2017-11-02 12:56:00 +01:00
1 parent 4e04a275c0
commit c22e5ead6b
5 files changed
+36 -35

No files matched your search

+2 -2
View File
@@ -29,7 +29,7 @@ class HTTPEncoderTests: XCTestCase {
XCTAssertFalse(try! channel.finish())
}
try! channel.pipeline.add(handler: HTTPResponseEncoder(allocator: channel.allocator)).wait()
try! channel.pipeline.add(handler: HTTPResponseEncoder()).wait()
var switchingResponse = HTTPResponseHead(version: HTTPVersion(major: 1, minor:1), status: status)
switchingResponse.headers = headers
try! channel.writeOutbound(data: HTTPResponsePart.head(switchingResponse))
@@ -98,7 +98,7 @@ class HTTPEncoderTests: XCTestCase {
XCTAssertFalse(try! channel.finish())
}
try! channel.pipeline.add(handler: HTTPResponseEncoder(allocator: channel.allocator)).wait()
try! channel.pipeline.add(handler: HTTPResponseEncoder()).wait()
// This response contains neither Transfer-Encoding: chunked or Content-Length.
let response = HTTPResponseHead(version: HTTPVersion(major: 1, minor:0), status: .ok)