HTTPResponseStatus should print code and reason (#2257)
* HTTPResponseStatus should print code and reason * Update HTTPResponseStatusTests+XCTest.swift Co-authored-by: Carolina Cassedy <ccassedy@apple.com> Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
parent
2c453d6e49
commit
028cf7e606
|
@ -1311,6 +1311,12 @@ extension HTTPRequestHead: CustomStringConvertible {
|
|||
}
|
||||
}
|
||||
|
||||
extension HTTPResponseStatus: CustomStringConvertible {
|
||||
public var description: String {
|
||||
return "\(self.code) \(self.reasonPhrase)"
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPResponseHead: CustomStringConvertible {
|
||||
public var description: String {
|
||||
return "HTTPResponseHead { version: \(self.version), status: \(self.status), headers: \(self.headers) }"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// This source file is part of the SwiftNIO open source project
|
||||
//
|
||||
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
|
||||
// Copyright (c) 2017-2022 Apple Inc. and the SwiftNIO project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
|
@ -28,6 +28,7 @@ extension HTTPResponseStatusTests {
|
|||
static var allTests : [(String, (HTTPResponseStatusTests) -> () throws -> Void)] {
|
||||
return [
|
||||
("testHTTPResponseStatusFromStatusCode", testHTTPResponseStatusFromStatusCode),
|
||||
("testHTTPResponseStatusCodeAndReason", testHTTPResponseStatusCodeAndReason),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,4 +81,10 @@ class HTTPResponseStatusTests: XCTestCase {
|
|||
XCTAssertEqual(HTTPResponseStatus(statusCode: 510), .notExtended)
|
||||
XCTAssertEqual(HTTPResponseStatus(statusCode: 511), .networkAuthenticationRequired)
|
||||
}
|
||||
|
||||
func testHTTPResponseStatusCodeAndReason() {
|
||||
XCTAssertEqual("\(HTTPResponseStatus.ok)", "200 OK")
|
||||
XCTAssertEqual("\(HTTPResponseStatus.imATeapot)", "418 I'm a teapot")
|
||||
XCTAssertEqual("\(HTTPResponseStatus.custom(code: 347, reasonPhrase: "I like ice cream"))", "347 I like ice cream")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue