Latest 3.3.1
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0, requires ARC
Frameworks Foundation


Build Status
Carthage compatible
Pod Version
Pod Platform
Pod License

Swift enum wrapper for easier handling of HTTP status codes.

The purpose of this library is to improve to clarify of code and remove the need for checking of status codes as numbers (==200), or as a range of values (== 2xx) – instead replacing it with descriptive enums.

All the RF2616 standard status codes are supported with a few added ones from the Wikipedia page.

As of version 3.0.0 of this framework, the list of status codes are directly generated from a online IANA CSV. The HTML page has a last updated field, and this is also mirrored in the header comments to identify which version this framework is currently using.
If this library is out of date compared to this page please open an issue and I will update the list.


Swift versions support

  • Swift 5 – use version 3.3.1
  • Swift 4 – use version 3.3.0
  • Swift 3 – use version 3.1
  • Older versions – use version 3.0



github "rhodgkins/SwiftHTTPStatusCodes" ~> 3.3

Source code:

import HTTPStatusCodes



pod 'HTTPStatusCodes', '~> 3.3.0'

Source code:

import HTTPStatusCodes


Or drop in the Swift files inside the Sources folder into your project.

Helper methods

There are Bool properties on the enum for checking if a status code is of a certain category:


There is also an extension on HTTPURLResponse to obtain a status code enum directly and to init with one:

var statusCodeValue: HTTPStatusCode?
init?(url: URL, statusCode: HTTPStatusCode, httpVersion: String?, headerFields: [String : String]?)

Latest podspec

    "name": "HTTPStatusCodes",
    "version": "3.3.1",
    "license": "MIT",
    "summary": "Swift enum wrapper for easier handling of HTTP status codes",
    "homepage": "",
    "social_media_url": "",
    "authors": "Rich Hodgkins",
    "source": {
        "git": "",
        "tag": "3.3.1"
    "swift_versions": [
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    "frameworks": "Foundation",
    "source_files": "Sources/*",
    "requires_arc": true

Pin It on Pinterest

Share This