Skip to content

Commit 183f75e

Browse files
committed
Formatting and linux tests
1 parent c9a2814 commit 183f75e

11 files changed

+26
-26
lines changed

Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
186186
case .sendRequestHead(let head, let sendEnd):
187187
self.sendRequestHead(head, sendEnd: sendEnd, context: context)
188188
case .notifyRequestHeadSendSuccessfully(let resumeRequestBodyStream, let startIdleTimer):
189-
190-
request!.requestHeadSent()
189+
190+
self.request!.requestHeadSent()
191191
if resumeRequestBodyStream {
192-
request!.resumeRequestBodyStream()
192+
self.request!.resumeRequestBodyStream()
193193
}
194194
if startIdleTimer {
195195
if let timeoutAction = self.idleReadTimeoutStateMachine?.requestEndSent() {

Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ConnectionStateMachine.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,9 @@ struct HTTP1ConnectionStateMachine {
354354
return state.modify(with: action)
355355
}
356356
}
357-
357+
358358
mutating func headSent() -> Action {
359-
guard case .inRequest(var requestStateMachine, let close) = state else {
359+
guard case .inRequest(var requestStateMachine, let close) = self.state else {
360360
return .wait
361361
}
362362
return self.avoidingStateMachineCoW { state in
@@ -479,7 +479,6 @@ extension HTTP1ConnectionStateMachine.State {
479479

480480
case .failSendStreamFinished(let error, let writePromise):
481481
return .failSendStreamFinished(error, writePromise)
482-
483482
}
484483
}
485484
}

Sources/AsyncHTTPClient/ConnectionPool/HTTP2/HTTP2ClientRequestHandler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ final class HTTP2ClientRequestHandler: ChannelDuplexHandler {
143143
case .sendRequestHead(let head, let sendEnd):
144144
self.sendRequestHead(head, sendEnd: sendEnd, context: context)
145145
case .notifyRequestHeadSendSuccessfully(let resumeRequestBodyStream, let startIdleTimer):
146-
request!.requestHeadSent()
146+
self.request!.requestHeadSent()
147147
if resumeRequestBodyStream {
148-
request!.resumeRequestBodyStream()
148+
self.request!.resumeRequestBodyStream()
149149
}
150150
if startIdleTimer {
151151
if let timeoutAction = self.idleReadTimeoutStateMachine?.requestEndSent() {

Sources/AsyncHTTPClient/ConnectionPool/HTTPRequestStateMachine.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ struct HTTPRequestStateMachine {
2323
/// - `.waitForChannelToBecomeWritable` (if the channel becomes non writable while sending the header)
2424
/// - `.sendingHead` if the channel is writable
2525
case initialized
26-
26+
2727
/// Waiting for the channel to be writable. Valid transitions are:
2828
/// - `.running(.streaming, .waitingForHead)` (once the Channel is writable again and if a request body is expected)
2929
/// - `.running(.endSent, .waitingForHead)` (once the Channel is writable again and no request body is expected)
3030
/// - `.failed` (if a connection error occurred)
3131
case waitForChannelToBecomeWritable(HTTPRequestHead, RequestFramingMetadata)
32-
32+
3333
/// A request is on the wire. Valid transitions are:
3434
/// - `.finished`
3535
/// - `.failed`
3636
case running(RequestState, ResponseState)
37-
37+
3838
/// The request has completed successfully
3939
case finished
40-
40+
4141
/// The request has failed
4242
case failed(Error)
4343

@@ -715,12 +715,12 @@ struct HTTPRequestStateMachine {
715715
return .sendRequestHead(head, sendEnd: false)
716716
}
717717
}
718-
718+
719719
mutating func headSent() -> Action {
720720
switch self.state {
721721
case .initialized, .waitForChannelToBecomeWritable, .finished:
722722
preconditionFailure("Not a valid transition after `.sendingHeader`: \(self.state)")
723-
723+
724724
case .running(.streaming(let expectedBodyLength, let sentBodyBytes, producer: .paused), let responseState):
725725
let startProducing = self.isChannelWritable && expectedBodyLength != sentBodyBytes
726726
self.state = .running(.streaming(
@@ -738,10 +738,9 @@ struct HTTPRequestStateMachine {
738738
preconditionFailure("request body producing can not start before we have successfully send the header \(self.state)")
739739
case .failed:
740740
return .wait
741-
741+
742742
case .modifying:
743743
preconditionFailure("Invalid state: \(self.state)")
744-
745744
}
746745
}
747746
}

Tests/AsyncHTTPClientTests/HTTP1ConnectionStateMachineTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class HTTP1ConnectionStateMachineTests: XCTestCase {
179179
XCTAssertEqual(newRequestAction, .sendRequestHead(requestHead, sendEnd: true))
180180

181181
XCTAssertEqual(state.channelInactive(), .failRequest(HTTPClientError.remoteConnectionClosed, .none))
182-
182+
183183
XCTAssertEqual(state.headSent(), .wait)
184184
}
185185

@@ -306,7 +306,7 @@ extension HTTP1ConnectionStateMachine.Action: Equatable {
306306

307307
case (.sendRequestHead(let lhsHead, let lhsStartBody), .sendRequestHead(let rhsHead, let rhsStartBody)):
308308
return lhsHead == rhsHead && lhsStartBody == rhsStartBody
309-
309+
310310
case (
311311
.notifyRequestHeadSendSuccessfully(let lhsResumeRequestBodyStream, let lhsStartIdleTimer),
312312
.notifyRequestHeadSendSuccessfully(let rhsResumeRequestBodyStream, let rhsStartIdleTimer)

Tests/AsyncHTTPClientTests/HTTP2ClientRequestHandlerTests+XCTest.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extension HTTP2ClientRequestHandlerTests {
3030
("testIdleReadTimeout", testIdleReadTimeout),
3131
("testIdleReadTimeoutIsCanceledIfRequestIsCanceled", testIdleReadTimeoutIsCanceledIfRequestIsCanceled),
3232
("testWriteHTTPHeadFails", testWriteHTTPHeadFails),
33+
("testChannelBecomesNonWritableDuringHeaderWrite", testChannelBecomesNonWritableDuringHeaderWrite),
3334
]
3435
}
3536
}

Tests/AsyncHTTPClientTests/HTTP2ClientRequestHandlerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class HTTP2ClientRequestHandlerTests: XCTestCase {
345345
XCTAssertEqual(embedded.isActive, false)
346346
}
347347
}
348-
348+
349349
func testChannelBecomesNonWritableDuringHeaderWrite() throws {
350350
final class ChangeWritabilityOnFlush: ChannelOutboundHandler {
351351
typealias OutboundIn = Any

Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ internal final class HTTPBin<RequestHandler: ChannelInboundHandler> where
343343
return compress
344344
}
345345
}
346-
346+
347347
var httpSettings: HTTP2Settings {
348348
switch self {
349349
case .http1_1, .http2(_, nil), .refuse:

Tests/AsyncHTTPClientTests/HTTPClientTests+XCTest.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ extension HTTPClientTests {
144144
("testMassiveDownload", testMassiveDownload),
145145
("testShutdownWithFutures", testShutdownWithFutures),
146146
("testMassiveHeaderHTTP1", testMassiveHeaderHTTP1),
147+
("testMassiveHeaderHTTP2", testMassiveHeaderHTTP2),
147148
]
148149
}
149150
}

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,22 +3377,22 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {
33773377

33783378
XCTAssertNoThrow(try defaultClient.execute(request: request).wait())
33793379
}
3380-
3380+
33813381
func testMassiveHeaderHTTP2() throws {
33823382
let bin = HTTPBin(.http2(settings: [
33833383
.init(parameter: .maxConcurrentStreams, value: 100),
33843384
.init(parameter: .maxHeaderListSize, value: 1024 * 256),
33853385
.init(parameter: .maxFrameSize, value: 1024 * 256),
33863386
]))
33873387
defer { XCTAssertNoThrow(try bin.shutdown()) }
3388-
3388+
33893389
let client = HTTPClient(
33903390
eventLoopGroupProvider: .shared(clientGroup),
33913391
configuration: .init(certificateVerification: .none)
33923392
)
3393-
3393+
33943394
defer { XCTAssertNoThrow(try client.syncShutdown()) }
3395-
3395+
33963396
var request = try HTTPClient.Request(url: bin.baseURL, method: .POST)
33973397
// add ~200 KB header
33983398
let headerValue = String(repeating: "0", count: 1024)

0 commit comments

Comments
 (0)