Skip to content

Commit 84026a7

Browse files
fabianfettartemredkin
authored andcommitted
ResponseAccumulator is now public (#155)
As discussed in #128. We make the ResponseAccumulator public to give developers an easy time to create a Task. With the ResponseAccumulator the developer using this does not have to worry, about implementing the HTTPClientResponseDelegate all by himself.
1 parent d5aa3a1 commit 84026a7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: Sources/AsyncHTTPClient/HTTPHandler.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ extension HTTPClient {
241241
}
242242
}
243243

244-
internal class ResponseAccumulator: HTTPClientResponseDelegate {
244+
public class ResponseAccumulator: HTTPClientResponseDelegate {
245245
public typealias Response = HTTPClient.Response
246246

247247
enum State {
@@ -255,11 +255,11 @@ internal class ResponseAccumulator: HTTPClientResponseDelegate {
255255
var state = State.idle
256256
let request: HTTPClient.Request
257257

258-
init(request: HTTPClient.Request) {
258+
public init(request: HTTPClient.Request) {
259259
self.request = request
260260
}
261261

262-
func didReceiveHead(task: HTTPClient.Task<Response>, _ head: HTTPResponseHead) -> EventLoopFuture<Void> {
262+
public func didReceiveHead(task: HTTPClient.Task<Response>, _ head: HTTPResponseHead) -> EventLoopFuture<Void> {
263263
switch self.state {
264264
case .idle:
265265
self.state = .head(head)
@@ -275,7 +275,7 @@ internal class ResponseAccumulator: HTTPClientResponseDelegate {
275275
return task.eventLoop.makeSucceededFuture(())
276276
}
277277

278-
func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ part: ByteBuffer) -> EventLoopFuture<Void> {
278+
public func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ part: ByteBuffer) -> EventLoopFuture<Void> {
279279
switch self.state {
280280
case .idle:
281281
preconditionFailure("no head received before body")
@@ -293,11 +293,11 @@ internal class ResponseAccumulator: HTTPClientResponseDelegate {
293293
return task.eventLoop.makeSucceededFuture(())
294294
}
295295

296-
func didReceiveError(task: HTTPClient.Task<Response>, _ error: Error) {
296+
public func didReceiveError(task: HTTPClient.Task<Response>, _ error: Error) {
297297
self.state = .error(error)
298298
}
299299

300-
func didFinishRequest(task: HTTPClient.Task<Response>) throws -> Response {
300+
public func didFinishRequest(task: HTTPClient.Task<Response>) throws -> Response {
301301
switch self.state {
302302
case .idle:
303303
preconditionFailure("no head received before end")

0 commit comments

Comments
 (0)