Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions Sources/AsyncHTTPClient/HTTPHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -628,20 +628,20 @@ public final class ResponseAccumulator: HTTPClientResponseDelegate {
}
}

public func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ part: ByteBuffer) -> EventLoopFuture<Void> {
public func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void> {
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)
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Sources/AsyncHTTPClient/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void>) throws {
()
}
Expand Down