@@ -2038,6 +2038,7 @@ class HTTPClientTests: XCTestCase {
20382038 defer {
20392039 XCTAssertNoThrow ( try httpClient. syncShutdown ( ) )
20402040 XCTAssertNoThrow ( try httpServer. stop ( ) )
2041+ XCTAssertNoThrow ( try elg. syncShutdownGracefully ( ) )
20412042 }
20422043
20432044 let delegate = TestDelegate ( eventLoop: second)
@@ -2069,10 +2070,17 @@ class HTTPClientTests: XCTestCase {
20692070 XCTAssertEqual ( error as! HTTPClientError , HTTPClientError . bodyLengthMismatch)
20702071 }
20712072 // Quickly try another request and check that it works.
2072- var response = try self . defaultClient. get ( url: self . defaultHTTPBinURLPrefix + " get " ) . wait ( )
2073- let info = try response. body!. readJSONDecodable ( RequestInfo . self, length: response. body!. readableBytes)
2074- XCTAssertEqual ( info!. connectionNumber, 1 )
2075- XCTAssertEqual ( info!. requestNumber, 1 )
2073+ let response = try self . defaultClient. get ( url: self . defaultHTTPBinURLPrefix + " get " ) . wait ( )
2074+ guard var body = response. body else {
2075+ XCTFail ( " Body missing: \( response) " )
2076+ return
2077+ }
2078+ guard let info = try body. readJSONDecodable ( RequestInfo . self, length: body. readableBytes) else {
2079+ XCTFail ( " Cannot parse body: \( body. readableBytesView. map { $0 } ) " )
2080+ return
2081+ }
2082+ XCTAssertEqual ( info. connectionNumber, 1 )
2083+ XCTAssertEqual ( info. requestNumber, 1 )
20762084 }
20772085
20782086 // currently gets stuck because of #250 the server just never replies
@@ -2089,9 +2097,16 @@ class HTTPClientTests: XCTestCase {
20892097 }
20902098 // Quickly try another request and check that it works. If we by accident wrote some extra bytes into the
20912099 // stream (and reuse the connection) that could cause problems.
2092- var response = try self . defaultClient. get ( url: self . defaultHTTPBinURLPrefix + " get " ) . wait ( )
2093- let info = try response. body!. readJSONDecodable ( RequestInfo . self, length: response. body!. readableBytes)
2094- XCTAssertEqual ( info!. connectionNumber, 1 )
2095- XCTAssertEqual ( info!. requestNumber, 1 )
2100+ let response = try self . defaultClient. get ( url: self . defaultHTTPBinURLPrefix + " get " ) . wait ( )
2101+ guard var body = response. body else {
2102+ XCTFail ( " Body missing: \( response) " )
2103+ return
2104+ }
2105+ guard let info = try body. readJSONDecodable ( RequestInfo . self, length: body. readableBytes) else {
2106+ XCTFail ( " Cannot parse body: \( body. readableBytesView. map { $0 } ) " )
2107+ return
2108+ }
2109+ XCTAssertEqual ( info. connectionNumber, 1 )
2110+ XCTAssertEqual ( info. requestNumber, 1 )
20962111 }
20972112}
0 commit comments