diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ef9ca1326..3f946796e 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -10,7 +10,7 @@ on: jobs: soundness: name: Soundness - uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.7 + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.13 with: license_header_check_project_name: "AsyncHTTPClient" unit-tests: diff --git a/Sources/AsyncHTTPClient/HTTPHandler.swift b/Sources/AsyncHTTPClient/HTTPHandler.swift index 4c4cc6f9a..1be979e68 100644 --- a/Sources/AsyncHTTPClient/HTTPHandler.swift +++ b/Sources/AsyncHTTPClient/HTTPHandler.swift @@ -628,20 +628,20 @@ public final class ResponseAccumulator: HTTPClientResponseDelegate { } } - public func didReceiveBodyPart(task: HTTPClient.Task, _ part: ByteBuffer) -> EventLoopFuture { + public func didReceiveBodyPart(task: HTTPClient.Task, _ buffer: ByteBuffer) -> EventLoopFuture { self.state.withLockedValue { switch $0.state { case .idle: preconditionFailure("no head received before body") case .head(let head): - guard part.readableBytes <= self.maxBodySize else { + guard buffer.readableBytes <= self.maxBodySize else { let error = ResponseTooBigError(maxBodySize: self.maxBodySize) $0.state = .error(error) return task.eventLoop.makeFailedFuture(error) } - $0.state = .body(head, part) + $0.state = .body(head, buffer) case .body(let head, var body): - let newBufferSize = body.writerIndex + part.readableBytes + let newBufferSize = body.writerIndex + buffer.readableBytes guard newBufferSize <= self.maxBodySize else { let error = ResponseTooBigError(maxBodySize: self.maxBodySize) $0.state = .error(error) @@ -653,8 +653,8 @@ public final class ResponseAccumulator: HTTPClientResponseDelegate { // `self.state` or we'll get a CoW. To fix that we temporarily set the state to `.end` (which // has no associated data). We'll fix it at the bottom of this block. $0.state = .end - var part = part - body.writeBuffer(&part) + var buffer = buffer + body.writeBuffer(&buffer) $0.state = .body(head, body) case .end: preconditionFailure("request already processed") diff --git a/Sources/AsyncHTTPClient/NIOTransportServices/NWErrorHandler.swift b/Sources/AsyncHTTPClient/NIOTransportServices/NWErrorHandler.swift index 704329b89..338fd8951 100644 --- a/Sources/AsyncHTTPClient/NIOTransportServices/NWErrorHandler.swift +++ b/Sources/AsyncHTTPClient/NIOTransportServices/NWErrorHandler.swift @@ -32,7 +32,7 @@ extension HTTPClient { /// Initialise a NWPOSIXError /// - Parameters: - /// - errorType: posix error type + /// - errorCode: posix error code /// - reason: String describing reason for error public init(_ errorCode: POSIXErrorCode, reason: String) { self.errorCode = errorCode diff --git a/Sources/AsyncHTTPClient/Utils.swift b/Sources/AsyncHTTPClient/Utils.swift index 985755143..43f711d5c 100644 --- a/Sources/AsyncHTTPClient/Utils.swift +++ b/Sources/AsyncHTTPClient/Utils.swift @@ -32,6 +32,9 @@ public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate, Sendab self.chunkHandler(buffer) } + /// Called when the complete HTTP request is finished. + /// + /// The body was already handed to the `chunkHandler` as it arrived, so there is nothing to return. public func didFinishRequest(task: HTTPClient.Task) throws { () }