Skip to content

Commit

Permalink
Added 599 status code (closes #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhodgkins committed Dec 14, 2017
1 parent 14fd312 commit c41c7ad
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
10 changes: 4 additions & 6 deletions Sources/HTTPStatusCodes+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public extension HTTPStatusCode {
@available(*, deprecated, renamed: "nginxClientClosedRequest")
static let clientClosedRequest = nginxClientClosedRequest

/// - deprecated: Renamed to `networkConnectTimeoutError`
@available(*, deprecated, renamed: "networkConnectTimeoutError")
static let networkTimeoutError = networkConnectTimeoutError

/// Returned by version 1 of the Twitter Search and Trends API when the client is being rate limited; versions 1.1 and later use the 429 Too Many Requests (`tooManyRequests`) response code instead.
///
/// - seealso: [Twitter Error Codes & Responses](https://dev.twitter.com/docs/error-codes-responses)
Expand Down Expand Up @@ -203,10 +207,4 @@ public extension HTTPStatusCode {
/// Removed and replaced with `RequestHeaderFieldsTooLarge` - 431
@available(*, unavailable, renamed: "requestHeaderFieldsTooLarge", message: "Changed to a 431 status code")
static let requestHeaderTooLarge = __Unavailable

/// Network Timeout Error: 599
///
/// Removed from Wikipedia page.
@available(*, unavailable, message: "No longer available")
static let networkTimeoutError = __Unavailable
}
5 changes: 5 additions & 0 deletions Sources/HTTPStatusCodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -406,5 +406,10 @@ import Foundation
///
/// Used by the [Pantheon](https://en.wikipedia.org/wiki/Pantheon_(software)) web platform to indicate a site that has been frozen due to inactivity.
case siteIsFrozen = 530

/// Network Connect Timeout Error: 599
///
/// This status code is not specified in any RFCs, but is used by some HTTP proxies to signal a network connect timeout behind the proxy to a client in front of the proxy.
case networkConnectTimeoutError = 599
}

4 changes: 4 additions & 0 deletions Tests/Generator.playground/Sources/StaticTexts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,9 @@ public let ExtraCases = [
"The server has exceeded the bandwidth specified by the server administrator; this is often used by shared hosting providers to limit the bandwidth of customers.",
"",
createSeeAlso(link: "https://documentation.cpanel.net/display/CKB/HTTP+Error+Codes+and+Quick+Fixes#HTTPErrorCodesandQuickFixes-509BandwidthLimitExceeded")
),
Case(code: 599,
name: "Network Connect Timeout Error",
comments: "This status code is not specified in any RFCs, but is used by some HTTP proxies to signal a network connect timeout behind the proxy to a client in front of the proxy."
)
]
8 changes: 3 additions & 5 deletions Tests/HTTPStatusCodes/Deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ FOUNDATION_EXTERN __HTTPStatusCode HTTPStatusCodeHTTPToHTTPS NS_SWIFT_UNAVAILABL
/// - deprecated: Renamed to `HTTPStatusCodeNginxClientClosedRequest`
FOUNDATION_EXTERN __HTTPStatusCode HTTPStatusCodeClientClosedRequest NS_SWIFT_UNAVAILABLE("Use HTTPStatusCode.clientClosedRequest instead") DEPRECATED_MSG_ATTRIBUTE("Renamed to HTTPStatusCodeNginxClientClosedRequest");

/// - deprecated: Renamed to `HTTPStatusCodeNetworkConnectTimeoutError`
FOUNDATION_EXTERN __HTTPStatusCode HTTPStatusCodeNetworkTimeoutError NS_SWIFT_UNAVAILABLE("Use HTTPStatusCode.networkTimeoutError instead") DEPRECATED_MSG_ATTRIBUTE("Renamed to HTTPStatusCodeNetworkConnectTimeoutError");;

/// Returned by version 1 of the Twitter Search and Trends API when the client is being rate limited; versions 1.1 and later use the 429 Too Many Requests response code instead.
///
/// - seealso: [Twitter Error Codes & Responses](https://dev.twitter.com/docs/error-codes-responses)
Expand Down Expand Up @@ -74,8 +77,3 @@ FOUNDATION_EXTERN __HTTPStatusCode HTTPStatusCodeSpringFrameworkMethodFailure NS
///
/// Removed and replaced with `RequestHeaderFieldsTooLarge` - 431
FOUNDATION_EXTERN __HTTPStatusCode HTTPStatusCodeRequestHeaderTooLarge NS_UNAVAILABLE;

/// Network Timeout Error: 599
///
/// Removed from Wikipedia page.
FOUNDATION_EXTERN __HTTPStatusCode HTTPStatusCodeNetworkTimeoutError NS_UNAVAILABLE;
2 changes: 1 addition & 1 deletion Tests/HTTPStatusCodes/Deprecated.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
__HTTPStatusCode HTTPStatusCodeNoCert = HTTPStatusCodeNginxSSLCertificateRequired;
__HTTPStatusCode HTTPStatusCodeHTTPToHTTPS = HTTPStatusCodeNginxHTTPToHTTPS;
__HTTPStatusCode HTTPStatusCodeClientClosedRequest = HTTPStatusCodeNginxClientClosedRequest;
__HTTPStatusCode HTTPStatusCodeNetworkTimeoutError = HTTPStatusCodeNetworkConnectTimeoutError;
__HTTPStatusCode HTTPStatusCodeTwitterEnhanceYourCalm = HTTPStatusCodeTooManyRequests;

// MARK: - Removed
Expand All @@ -30,4 +31,3 @@
__HTTPStatusCode HTTPStatusCodeAuthenticationTimeout = 419;
__HTTPStatusCode HTTPStatusCodeSpringFrameworkMethodFailure = 419;
__HTTPStatusCode HTTPStatusCodeRequestHeaderTooLarge = 494;
__HTTPStatusCode HTTPStatusCodeNetworkTimeoutError = 599;
3 changes: 2 additions & 1 deletion Tests/HTTPStatusCodesTests/ObjectiveCRegressionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ -(void)testVersion2_0
XCTAssertEqual(HTTPStatusCodeBandwidthLimitExceeded, 509);
XCTAssertEqual(HTTPStatusCodeNotExtended, 510);
XCTAssertEqual(HTTPStatusCodeNetworkAuthenticationRequired, 511);
// XCTAssertEqual(HTTPStatusCodeNetworkTimeoutError, 599);
XCTAssertEqual(HTTPStatusCodeNetworkTimeoutError, 599);
}

-(void)testVersion3_0
Expand Down Expand Up @@ -175,6 +175,7 @@ -(void)testVersion3_0
XCTAssertEqual(HTTPStatusCodeNotExtended, 510);
XCTAssertEqual(HTTPStatusCodeNetworkAuthenticationRequired, 511);
XCTAssertEqual(HTTPStatusCodeSiteIsFrozen, 530);
XCTAssertEqual(HTTPStatusCodeNetworkConnectTimeoutError, 599);
}

@end
Expand Down
3 changes: 2 additions & 1 deletion Tests/HTTPStatusCodesTests/RegressionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ final class RegressionTests: XCTestCase {
XCTAssertEqual(HTTPStatusCode.bandwidthLimitExceeded, 509)
XCTAssertEqual(HTTPStatusCode.notExtended, 510)
XCTAssertEqual(HTTPStatusCode.networkAuthenticationRequired, 511)
// XCTAssertEqual(HTTPStatusCode.networkTimeoutError, 599)
XCTAssertEqual(HTTPStatusCode.networkTimeoutError, 599)
}

func testVersion3_0() {
Expand Down Expand Up @@ -182,6 +182,7 @@ final class RegressionTests: XCTestCase {
XCTAssertEqual(HTTPStatusCode.notExtended, 510)
XCTAssertEqual(HTTPStatusCode.networkAuthenticationRequired, 511)
XCTAssertEqual(HTTPStatusCode.siteIsFrozen, 530)
XCTAssertEqual(HTTPStatusCode.networkConnectTimeoutError, 599)

XCTAssertEqual(HTTPURLResponse(url: URL(string: "http://www.google.com")!, statusCode: .ok, HTTPVersion: nil, headerFields: nil)!.statusCodeValue, .ok)
}
Expand Down

0 comments on commit c41c7ad

Please sign in to comment.