mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
ChannelPipeline: addHandler and removeHandler instead of add/remove (#817)
Motivation: - `ChannelPipeline.add(name:handler:...)` had a strange order of arguments - `remove(handler:)` and `remove(ctx:)` both remove `ChannelHandler`s but they read like they remove different things So let's just fix the argument order and name them `addHandler` and `removeHandler` making clear what they do. Modifications: - rename all `ChannelPipeline.add(name:handler:...)`s to `ChannelPipeline.addHandler(_:name:...)` - rename all `ChannelPipeline.remove(...)`s to `ChannelPipeline.removeHandler(...)` Result: more readable and consistent code
This commit is contained in:
1 parent
5d27e59bd9
commit
46ffd630de
50 files changed
+539
-425
No files matched your search
@@ -29,7 +29,7 @@ class HTTPRequestEncoderTests: XCTestCase {
|
||||
XCTAssertEqual(.some(false), try? channel.finish())
|
||||
}
|
||||
|
||||
try channel.pipeline.add(handler: HTTPRequestEncoder()).wait()
|
||||
try channel.pipeline.addHandler(HTTPRequestEncoder()).wait()
|
||||
var request = HTTPRequestHead(version: HTTPVersion(major: 1, minor:1), method: method, uri: "/uri")
|
||||
request.headers = headers
|
||||
try channel.writeOutbound(HTTPClientRequestPart.head(request))
|
||||
@@ -78,7 +78,7 @@ class HTTPRequestEncoderTests: XCTestCase {
|
||||
XCTAssertEqual(.some(false), try? channel.finish())
|
||||
}
|
||||
|
||||
XCTAssertNoThrow(try channel.pipeline.add(handler: HTTPRequestEncoder()).wait())
|
||||
XCTAssertNoThrow(try channel.pipeline.addHandler(HTTPRequestEncoder()).wait())
|
||||
|
||||
// This request contains neither Transfer-Encoding: chunked or Content-Length.
|
||||
let request = HTTPRequestHead(version: HTTPVersion(major: 1, minor:0), method: .GET, uri: "/uri")
|
||||
@@ -94,7 +94,7 @@ class HTTPRequestEncoderTests: XCTestCase {
|
||||
XCTAssertEqual(.some(false), try? channel.finish())
|
||||
}
|
||||
|
||||
try channel.pipeline.add(handler: HTTPRequestEncoder()).wait()
|
||||
try channel.pipeline.addHandler(HTTPRequestEncoder()).wait()
|
||||
var request = HTTPRequestHead(version: HTTPVersion(major: 1, minor:1), method: .POST, uri: "/uri")
|
||||
request.headers.add(name: "content-length", value: "4")
|
||||
|
||||
@@ -117,7 +117,7 @@ class HTTPRequestEncoderTests: XCTestCase {
|
||||
}
|
||||
|
||||
let uri = "server.example.com:80"
|
||||
try channel.pipeline.add(handler: HTTPRequestEncoder()).wait()
|
||||
try channel.pipeline.addHandler(HTTPRequestEncoder()).wait()
|
||||
var request = HTTPRequestHead(version: HTTPVersion(major: 1, minor:1), method: .CONNECT, uri: uri)
|
||||
request.headers.add(name: "Host", value: uri)
|
||||
|
||||
|
||||
Reference in new issue
Block a user