Skip to content

Commit e675f60

Browse files
committed
Run generate_linux_tests.rb and SwiftFormat
1 parent d4d61f7 commit e675f60

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

Sources/AsyncHTTPClient/HTTPHandler.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ extension HTTPClient {
356356
///
357357
/// This ``HTTPClientResponseDelegate`` buffers a complete HTTP response in memory. It does not stream the response body in.
358358
/// The resulting ``Response`` type is ``HTTPClient/Response``.
359-
final public class ResponseAccumulator: HTTPClientResponseDelegate {
359+
public final class ResponseAccumulator: HTTPClientResponseDelegate {
360360
public typealias Response = HTTPClient.Response
361361

362362
enum State {
@@ -366,29 +366,29 @@ final public class ResponseAccumulator: HTTPClientResponseDelegate {
366366
case end
367367
case error(Error)
368368
}
369-
369+
370370
public struct ResponseTooBigError: Error, CustomStringConvertible {
371371
var maxBodySize: Int
372-
372+
373373
public var description: String {
374-
return "ResponseTooBigError: received response body exceeds maximum accepted size of \(maxBodySize) bytes"
374+
return "ResponseTooBigError: received response body exceeds maximum accepted size of \(self.maxBodySize) bytes"
375375
}
376376
}
377377

378378
var state = State.idle
379379
let request: HTTPClient.Request
380-
380+
381381
static let maxByteBufferSize = Int(UInt32.max)
382-
382+
383383
/// Maximum size in bytes of the HTTP response body that ``ResponseAccumulator`` will accept
384384
/// until it will abort the request and throw an ``ResponseTooBigError``.
385-
///
385+
///
386386
/// Default is 2^32.
387387
/// - precondition: not allowed to exceed 2^32 because ``ByteBuffer`` can not store more bytes
388388
public var maxBodySize: Int = maxByteBufferSize {
389389
didSet {
390390
precondition(
391-
maxBodySize <= Self.maxByteBufferSize,
391+
self.maxBodySize <= Self.maxByteBufferSize,
392392
"maxBodyLength is not allowed to exceed 2^32 because ByteBuffer can not store more bytes"
393393
)
394394
}
@@ -408,7 +408,7 @@ final public class ResponseAccumulator: HTTPClientResponseDelegate {
408408
self.state = .error(error)
409409
return task.eventLoop.makeFailedFuture(error)
410410
}
411-
411+
412412
self.state = .head(head)
413413
case .head:
414414
preconditionFailure("head already set")
@@ -440,7 +440,7 @@ final public class ResponseAccumulator: HTTPClientResponseDelegate {
440440
self.state = .error(error)
441441
return task.eventLoop.makeFailedFuture(error)
442442
}
443-
443+
444444
// The compiler can't prove that `self.state` is dead here (and it kinda isn't, there's
445445
// a cross-module call in the way) so we need to drop the original reference to `body` in
446446
// `self.state` or we'll get a CoW. To fix that we temporarily set the state to `.end` (which

Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,7 @@ internal final class HTTPBin<RequestHandler: ChannelInboundHandler> where
365365
var socketAddress: SocketAddress {
366366
return self.serverChannel.localAddress!
367367
}
368-
369-
368+
370369
var baseURL: String {
371370
let scheme: String = {
372371
switch mode {

Tests/AsyncHTTPClientTests/HTTPClientTests+XCTest.swift

+4
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ extension HTTPClientTests {
132132
("testSSLHandshakeErrorPropagationDelayedClose", testSSLHandshakeErrorPropagationDelayedClose),
133133
("testWeCloseConnectionsWhenConnectionCloseSetByServer", testWeCloseConnectionsWhenConnectionCloseSetByServer),
134134
("testBiDirectionalStreaming", testBiDirectionalStreaming),
135+
("testResponseAccumulatorMaxBodySizeLimitExceedingWithContentLength", testResponseAccumulatorMaxBodySizeLimitExceedingWithContentLength),
136+
("testResponseAccumulatorMaxBodySizeLimitNotExceedingWithContentLength", testResponseAccumulatorMaxBodySizeLimitNotExceedingWithContentLength),
137+
("testResponseAccumulatorMaxBodySizeLimitExceedingWithTransferEncodingChuncked", testResponseAccumulatorMaxBodySizeLimitExceedingWithTransferEncodingChuncked),
138+
("testResponseAccumulatorMaxBodySizeLimitNotExceedingWithTransferEncodingChuncked", testResponseAccumulatorMaxBodySizeLimitNotExceedingWithTransferEncodingChuncked),
135139
("testBiDirectionalStreamingEarly200", testBiDirectionalStreamingEarly200),
136140
("testBiDirectionalStreamingEarly200DoesntPreventUsFromSendingMoreRequests", testBiDirectionalStreamingEarly200DoesntPreventUsFromSendingMoreRequests),
137141
("testCloseConnectionAfterEarly2XXWhenStreaming", testCloseConnectionAfterEarly2XXWhenStreaming),

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

+14-14
Original file line numberDiff line numberDiff line change
@@ -3091,13 +3091,13 @@ class HTTPClientTests: XCTestCase {
30913091
XCTAssertNoThrow(try future.wait())
30923092
XCTAssertNil(try delegate.next().wait())
30933093
}
3094-
3094+
30953095
func testResponseAccumulatorMaxBodySizeLimitExceedingWithContentLength() throws {
30963096
let httpBin = HTTPBin(.http1_1(ssl: false, compress: false)) { _ in HTTPEchoHandler() }
30973097
defer { XCTAssertNoThrow(try httpBin.shutdown()) }
3098-
3098+
30993099
let body = ByteBuffer(bytes: 0..<11)
3100-
3100+
31013101
var request = try Request(url: httpBin.baseURL)
31023102
request.body = .byteBuffer(body)
31033103
let delegate = ResponseAccumulator(request: request)
@@ -3109,13 +3109,13 @@ class HTTPClientTests: XCTestCase {
31093109
XCTAssertTrue(error is ResponseAccumulator.ResponseTooBigError, "unexpected error \(error)")
31103110
}
31113111
}
3112-
3112+
31133113
func testResponseAccumulatorMaxBodySizeLimitNotExceedingWithContentLength() throws {
31143114
let httpBin = HTTPBin(.http1_1(ssl: false, compress: false)) { _ in HTTPEchoHandler() }
31153115
defer { XCTAssertNoThrow(try httpBin.shutdown()) }
3116-
3116+
31173117
let body = ByteBuffer(bytes: 0..<10)
3118-
3118+
31193119
var request = try Request(url: httpBin.baseURL)
31203120
request.body = .byteBuffer(body)
31213121
let delegate = ResponseAccumulator(request: request)
@@ -3124,16 +3124,16 @@ class HTTPClientTests: XCTestCase {
31243124
request: request,
31253125
delegate: delegate
31263126
).wait()
3127-
3127+
31283128
XCTAssertEqual(response.body, body)
31293129
}
3130-
3130+
31313131
func testResponseAccumulatorMaxBodySizeLimitExceedingWithTransferEncodingChuncked() throws {
31323132
let httpBin = HTTPBin(.http1_1(ssl: false, compress: false)) { _ in HTTPEchoHandler() }
31333133
defer { XCTAssertNoThrow(try httpBin.shutdown()) }
3134-
3134+
31353135
let body = ByteBuffer(bytes: 0..<11)
3136-
3136+
31373137
var request = try Request(url: httpBin.baseURL)
31383138
request.body = .stream { writer in
31393139
writer.write(.byteBuffer(body))
@@ -3147,13 +3147,13 @@ class HTTPClientTests: XCTestCase {
31473147
XCTAssertTrue(error is ResponseAccumulator.ResponseTooBigError, "unexpected error \(error)")
31483148
}
31493149
}
3150-
3150+
31513151
func testResponseAccumulatorMaxBodySizeLimitNotExceedingWithTransferEncodingChuncked() throws {
31523152
let httpBin = HTTPBin(.http1_1(ssl: false, compress: false)) { _ in HTTPEchoHandler() }
31533153
defer { XCTAssertNoThrow(try httpBin.shutdown()) }
3154-
3154+
31553155
let body = ByteBuffer(bytes: 0..<10)
3156-
3156+
31573157
var request = try Request(url: httpBin.baseURL)
31583158
request.body = .stream { writer in
31593159
writer.write(.byteBuffer(body))
@@ -3164,7 +3164,7 @@ class HTTPClientTests: XCTestCase {
31643164
request: request,
31653165
delegate: delegate
31663166
).wait()
3167-
3167+
31683168
XCTAssertEqual(response.body, body)
31693169
}
31703170

0 commit comments

Comments
 (0)