Skip to content

Commit 912b5fe

Browse files
committed
Merge branch 'master' into add_event_loop_in_execute
2 parents db26532 + e9d0dd2 commit 912b5fe

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class CountingDelegate: HTTPClientResponseDelegate {
136136
return task.eventLoop.makeSucceededFuture(())
137137
}
138138

139-
func didReceivePart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
139+
func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
140140
// this is executed when we receive parts of the response body, could be called zero or more times
141141
count += buffer.readableBytes
142142
// in case backpressure is needed, all reads will be paused until returned future is resolved

Sources/AsyncHTTPClient/HTTPHandler.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ internal class ResponseAccumulator: HTTPClientResponseDelegate {
230230
return task.eventLoop.makeSucceededFuture(())
231231
}
232232

233-
func didReceivePart(task: HTTPClient.Task<Response>, _ part: ByteBuffer) -> EventLoopFuture<Void> {
233+
func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ part: ByteBuffer) -> EventLoopFuture<Void> {
234234
switch self.state {
235235
case .idle:
236236
preconditionFailure("no head received before body")
@@ -319,7 +319,7 @@ public protocol HTTPClientResponseDelegate: AnyObject {
319319
/// - task: Current request context.
320320
/// - buffer: Received body `Part`.
321321
/// - returns: `EventLoopFuture` that will be used for backpressure.
322-
func didReceivePart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void>
322+
func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void>
323323

324324
/// Called when error was thrown during request execution. Will be called zero or one time only. Request processing will be stopped after that.
325325
///
@@ -345,7 +345,7 @@ extension HTTPClientResponseDelegate {
345345

346346
public func didReceiveHead(task: HTTPClient.Task<Response>, _: HTTPResponseHead) -> EventLoopFuture<Void> { return task.eventLoop.makeSucceededFuture(()) }
347347

348-
public func didReceivePart(task: HTTPClient.Task<Response>, _: ByteBuffer) -> EventLoopFuture<Void> { return task.eventLoop.makeSucceededFuture(()) }
348+
public func didReceiveBodyPart(task: HTTPClient.Task<Response>, _: ByteBuffer) -> EventLoopFuture<Void> { return task.eventLoop.makeSucceededFuture(()) }
349349

350350
public func didReceiveError(task: HTTPClient.Task<Response>, _: Error) {}
351351
}
@@ -550,7 +550,7 @@ internal class TaskHandler<T: HTTPClientResponseDelegate>: ChannelInboundHandler
550550
default:
551551
self.state = .body
552552
self.mayRead = false
553-
self.delegate.didReceivePart(task: self.task, body).whenComplete { result in
553+
self.delegate.didReceiveBodyPart(task: self.task, body).whenComplete { result in
554554
self.handleBackpressureResult(context: context, result: result)
555555
}
556556
}

Sources/AsyncHTTPClient/Utils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate {
2424
self.chunkHandler = chunkHandler
2525
}
2626

27-
public func didReceivePart(task: HTTPClient.Task<Void>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
27+
public func didReceiveBodyPart(task: HTTPClient.Task<Void>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
2828
return self.chunkHandler(buffer)
2929
}
3030

Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class HTTPClientInternalTests: XCTestCase {
153153
}
154154
}
155155

156-
func didReceivePart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
156+
func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
157157
self.lock.withLockVoid {
158158
self._reads += 1
159159
}

Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class TestHTTPDelegate: HTTPClientResponseDelegate {
3636
return task.eventLoop.makeSucceededFuture(())
3737
}
3838

39-
func didReceivePart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
39+
func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
4040
switch self.state {
4141
case .head(let head):
4242
self.state = .body(head, buffer)
@@ -58,7 +58,7 @@ class CountingDelegate: HTTPClientResponseDelegate {
5858

5959
var count = 0
6060

61-
func didReceivePart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
61+
func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
6262
let str = buffer.getString(at: 0, length: buffer.readableBytes)
6363
if str?.starts(with: "id:") ?? false {
6464
self.count += 1
@@ -97,8 +97,8 @@ internal class HttpBin {
9797
}
9898

9999
static func configureTLS(channel: Channel) -> EventLoopFuture<Void> {
100-
let configuration = TLSConfiguration.forServer(certificateChain: [.certificate(try! NIOSSLCertificate(buffer: cert.utf8.map(Int8.init), format: .pem))],
101-
privateKey: .privateKey(try! NIOSSLPrivateKey(buffer: key.utf8.map(Int8.init), format: .pem)))
100+
let configuration = TLSConfiguration.forServer(certificateChain: [.certificate(try! NIOSSLCertificate(bytes: Array(cert.utf8), format: .pem))],
101+
privateKey: .privateKey(try! NIOSSLPrivateKey(bytes: Array(key.utf8), format: .pem)))
102102
let context = try! NIOSSLContext(configuration: configuration)
103103
return channel.pipeline.addHandler(try! NIOSSLServerHandler(context: context), position: .first)
104104
}
@@ -347,8 +347,8 @@ internal class HttpBinForSSLUncleanShutdown {
347347
.childChannelInitializer { channel in
348348
let requestDecoder = HTTPRequestDecoder()
349349
return channel.pipeline.addHandler(ByteToMessageHandler(requestDecoder)).flatMap {
350-
let configuration = TLSConfiguration.forServer(certificateChain: [.certificate(try! NIOSSLCertificate(buffer: cert.utf8.map(Int8.init), format: .pem))],
351-
privateKey: .privateKey(try! NIOSSLPrivateKey(buffer: key.utf8.map(Int8.init), format: .pem)))
350+
let configuration = TLSConfiguration.forServer(certificateChain: [.certificate(try! NIOSSLCertificate(bytes: Array(cert.utf8), format: .pem))],
351+
privateKey: .privateKey(try! NIOSSLPrivateKey(bytes: Array(key.utf8), format: .pem)))
352352
let context = try! NIOSSLContext(configuration: configuration)
353353
return channel.pipeline.addHandler(try! NIOSSLServerHandler(context: context), name: "NIOSSLServerHandler", position: .first).flatMap {
354354
channel.pipeline.addHandler(HttpBinForSSLUncleanShutdownHandler(channelPromise: channelPromise))

0 commit comments

Comments
 (0)