Fastly Compute C++ SDK
Loading...
Searching...
No Matches
fastly::http::StatusCode Class Reference

#include <status_code.h>

Public Member Functions

 StatusCode ()=default
constexpr StatusCode (uint16_t code)
 Creates a new StatusCode. Panics if the code is out of range.
constexpr bool operator== (StatusCode a) const
constexpr bool operator!= (StatusCode a) const
 operator bool () const =delete
std::optional< StatusCodefrom_code (uint16_t code)
uint16_t as_code ()
 Returns the uint16_t corresponding to this StatusCode.
tl::expected< std::optional< std::string >, fastly::FastlyErrorcanonical_reason ()
bool is_informational ()
 Check if status is within 100-199.
bool is_success ()
 Check if status is within 200-299.
bool is_redirection ()
 Check if status is within 300-399.
bool is_client_error ()
 Check if status is within 400-499.
bool is_server_error ()
 Check if status is within 500-599.

Static Public Attributes

static const StatusCode CONTINUE
static const StatusCode SWITCHING_PROTOCOLS
static const StatusCode PROCESSING
static const StatusCode OK
static const StatusCode CREATED
static const StatusCode ACCEPTED
static const StatusCode NON_AUTHORITATIVE_INFORMATION
static const StatusCode NO_CONTENT
static const StatusCode RESET_CONTENT
static const StatusCode PARTIAL_CONTENT
static const StatusCode MULTI_STATUS
static const StatusCode ALREADY_REPORTED
static const StatusCode IM_USED
static const StatusCode MULTIPLE_CHOICES
static const StatusCode MOVED_PERMANENTLY
static const StatusCode FOUND
static const StatusCode SEE_OTHER
static const StatusCode NOT_MODIFIED
static const StatusCode USE_PROXY
static const StatusCode TEMPORARY_REDIRECT
static const StatusCode PERMANENT_REDIRECT
static const StatusCode BAD_REQUEST
static const StatusCode UNAUTHORIZED
static const StatusCode PAYMENT_REQUIRED
static const StatusCode FORBIDDEN
static const StatusCode NOT_FOUND
static const StatusCode METHOD_NOT_ALLOWED
static const StatusCode NOT_ACCEPTABLE
static const StatusCode PROXY_AUTHENTICATION_REQUIRED
static const StatusCode REQUEST_TIMEOUT
static const StatusCode CONFLICT
static const StatusCode GONE
static const StatusCode LENGTH_REQUIRED
static const StatusCode PRECONDITION_FAILED
static const StatusCode PAYLOAD_TOO_LARGE
static const StatusCode URI_TOO_LONG
static const StatusCode UNSUPPORTED_MEDIA_TYPE
static const StatusCode RANGE_NOT_SATISFIABLE
static const StatusCode EXPECTATION_FAILED
static const StatusCode IM_A_TEAPOT
static const StatusCode MISDIRECTED_REQUEST
static const StatusCode UNPROCESSABLE_ENTITY
static const StatusCode LOCKED
static const StatusCode FAILED_DEPENDENCY
static const StatusCode TOO_EARLY
static const StatusCode UPGRADE_REQUIRED
static const StatusCode PRECONDITION_REQUIRED
static const StatusCode TOO_MANY_REQUESTS
static const StatusCode REQUEST_HEADER_FIELDS_TOO_LARGE
static const StatusCode UNAVAILABLE_FOR_LEGAL_REASONS
static const StatusCode INTERNAL_SERVER_ERROR
static const StatusCode NOT_IMPLEMENTED
static const StatusCode BAD_GATEWAY
static const StatusCode SERVICE_UNAVAILABLE
static const StatusCode GATEWAY_TIMEOUT
static const StatusCode HTTP_VERSION_NOT_SUPPORTED
static const StatusCode VARIANT_ALSO_NEGOTIATES
static const StatusCode INSUFFICIENT_STORAGE
static const StatusCode LOOP_DETECTED
static const StatusCode NOT_EXTENDED
static const StatusCode NETWORK_AUTHENTICATION_REQUIRED

Constructor & Destructor Documentation

◆ StatusCode() [1/2]

fastly::http::StatusCode::StatusCode ( )
default

◆ StatusCode() [2/2]

fastly::http::StatusCode::StatusCode ( uint16_t code)
inlineconstexpr

Creates a new StatusCode. Panics if the code is out of range.

Member Function Documentation

◆ as_code()

uint16_t fastly::http::StatusCode::as_code ( )

Returns the uint16_t corresponding to this StatusCode.

◆ canonical_reason()

tl::expected< std::optional< std::string >, fastly::FastlyError > fastly::http::StatusCode::canonical_reason ( )

Get the standardised reason-phrase for this status code.

This is mostly here for servers writing responses, but could potentially have application at other times.

The reason phrase is defined as being exclusively for human readers. You should avoid deriving any meaning from it at all costs.

Bear in mind also that in HTTP/2.0 and HTTP/3.0 the reason phrase is abolished from transmission, and so this canonical reason phrase really is the only reason phrase you’ll find.

Example

assert(status.canonical_reason() == std::optional("OK"s)));
static const StatusCode OK
Definition status_code.h:41

◆ from_code()

std::optional< StatusCode > fastly::http::StatusCode::from_code ( uint16_t code)

Converts a uint16_t to a status code, returning it wrapped in an std::optional.

The method validates the correctness of the supplied uint16_t. It must be greater or equal to 100 and less than 1000, or this method will return std::nullopt.

◆ is_client_error()

bool fastly::http::StatusCode::is_client_error ( )

Check if status is within 400-499.

◆ is_informational()

bool fastly::http::StatusCode::is_informational ( )

Check if status is within 100-199.

◆ is_redirection()

bool fastly::http::StatusCode::is_redirection ( )

Check if status is within 300-399.

◆ is_server_error()

bool fastly::http::StatusCode::is_server_error ( )

Check if status is within 500-599.

◆ is_success()

bool fastly::http::StatusCode::is_success ( )

Check if status is within 200-299.

◆ operator bool()

fastly::http::StatusCode::operator bool ( ) const
explicitdelete

◆ operator!=()

bool fastly::http::StatusCode::operator!= ( StatusCode a) const
inlineconstexpr

◆ operator==()

bool fastly::http::StatusCode::operator== ( StatusCode a) const
inlineconstexpr

Member Data Documentation

◆ ACCEPTED

const StatusCode fastly::http::StatusCode::ACCEPTED
static

202 Accepted [RFC9110, Section 15.3.3]

◆ ALREADY_REPORTED

const StatusCode fastly::http::StatusCode::ALREADY_REPORTED
static

208 Already Reported [RFC5842, Section 7.1]

◆ BAD_GATEWAY

const StatusCode fastly::http::StatusCode::BAD_GATEWAY
static

502 Bad Gateway [RFC9110, Section 15.6.3]

◆ BAD_REQUEST

const StatusCode fastly::http::StatusCode::BAD_REQUEST
static

◆ CONFLICT

const StatusCode fastly::http::StatusCode::CONFLICT
static

409 Conflict [RFC9110, Section 15.5.10]

◆ CONTINUE

const StatusCode fastly::http::StatusCode::CONTINUE
static

100 Continue [RFC9110, Section 15.2.1]

◆ CREATED

const StatusCode fastly::http::StatusCode::CREATED
static

201 Created [RFC9110, Section 15.3.2]

◆ EXPECTATION_FAILED

const StatusCode fastly::http::StatusCode::EXPECTATION_FAILED
static

417 Expectation Failed [RFC9110, Section 15.5.18]

◆ FAILED_DEPENDENCY

const StatusCode fastly::http::StatusCode::FAILED_DEPENDENCY
static

424 Failed Dependency [RFC4918, Section 11.4]

◆ FORBIDDEN

const StatusCode fastly::http::StatusCode::FORBIDDEN
static

403 Forbidden [RFC9110, Section 15.5.4]

◆ FOUND

const StatusCode fastly::http::StatusCode::FOUND
static

◆ GATEWAY_TIMEOUT

const StatusCode fastly::http::StatusCode::GATEWAY_TIMEOUT
static

504 Gateway Timeout [RFC9110, Section 15.6.5]

◆ GONE

const StatusCode fastly::http::StatusCode::GONE
static

◆ HTTP_VERSION_NOT_SUPPORTED

const StatusCode fastly::http::StatusCode::HTTP_VERSION_NOT_SUPPORTED
static

505 HTTP Version Not Supported [RFC9110, Section 15.6.6]

◆ IM_A_TEAPOT

const StatusCode fastly::http::StatusCode::IM_A_TEAPOT
static

418 I'm a teapot [curiously not registered by IANA but RFC2324, Section 2.3.2]

◆ IM_USED

const StatusCode fastly::http::StatusCode::IM_USED
static

226 IM Used [RFC3229, Section 10.4.1]

◆ INSUFFICIENT_STORAGE

const StatusCode fastly::http::StatusCode::INSUFFICIENT_STORAGE
static

507 Insufficient Storage [RFC4918, Section 11.5]

◆ INTERNAL_SERVER_ERROR

const StatusCode fastly::http::StatusCode::INTERNAL_SERVER_ERROR
static

500 Internal Server Error [RFC9110, Section 15.6.1]

Examples
async_reqs.cpp, and streaming_response.cpp.

◆ LENGTH_REQUIRED

const StatusCode fastly::http::StatusCode::LENGTH_REQUIRED
static

411 Length Required [RFC9110, Section 15.5.12]

◆ LOCKED

const StatusCode fastly::http::StatusCode::LOCKED
static

423 Locked [RFC4918, Section 11.3]

◆ LOOP_DETECTED

const StatusCode fastly::http::StatusCode::LOOP_DETECTED
static

508 Loop Detected [RFC5842, Section 7.2]

◆ METHOD_NOT_ALLOWED

const StatusCode fastly::http::StatusCode::METHOD_NOT_ALLOWED
static

405 Method Not Allowed [RFC9110, Section 15.5.6]

◆ MISDIRECTED_REQUEST

const StatusCode fastly::http::StatusCode::MISDIRECTED_REQUEST
static

421 Misdirected Request [RFC9110, Section 15.5.20]

◆ MOVED_PERMANENTLY

const StatusCode fastly::http::StatusCode::MOVED_PERMANENTLY
static

301 Moved Permanently [RFC9110, Section 15.4.2]

◆ MULTI_STATUS

const StatusCode fastly::http::StatusCode::MULTI_STATUS
static

207 Multi-Status [RFC4918, Section 11.1]

◆ MULTIPLE_CHOICES

const StatusCode fastly::http::StatusCode::MULTIPLE_CHOICES
static

300 Multiple Choices [RFC9110, Section 15.4.1]

◆ NETWORK_AUTHENTICATION_REQUIRED

const StatusCode fastly::http::StatusCode::NETWORK_AUTHENTICATION_REQUIRED
static

511 Network Authentication Required [RFC6585, Section 6]

◆ NO_CONTENT

const StatusCode fastly::http::StatusCode::NO_CONTENT
static

204 No Content [RFC9110, Section 15.3.5]

◆ NON_AUTHORITATIVE_INFORMATION

const StatusCode fastly::http::StatusCode::NON_AUTHORITATIVE_INFORMATION
static

203 Non-Authoritative Information [RFC9110, Section 15.3.4]

◆ NOT_ACCEPTABLE

const StatusCode fastly::http::StatusCode::NOT_ACCEPTABLE
static

406 Not Acceptable [RFC9110, Section 15.5.7]

◆ NOT_EXTENDED

const StatusCode fastly::http::StatusCode::NOT_EXTENDED
static

510 Not Extended [RFC2774, Section 7]

◆ NOT_FOUND

const StatusCode fastly::http::StatusCode::NOT_FOUND
static

404 Not Found [RFC9110, Section 15.5.5]

Examples
robots.txt.cpp.

◆ NOT_IMPLEMENTED

const StatusCode fastly::http::StatusCode::NOT_IMPLEMENTED
static

501 Not Implemented [RFC9110, Section 15.6.2]

◆ NOT_MODIFIED

const StatusCode fastly::http::StatusCode::NOT_MODIFIED
static

304 Not Modified [RFC9110, Section 15.4.5]

◆ OK

const StatusCode fastly::http::StatusCode::OK
static

◆ PARTIAL_CONTENT

const StatusCode fastly::http::StatusCode::PARTIAL_CONTENT
static

206 Partial Content [RFC9110, Section 15.3.7]

◆ PAYLOAD_TOO_LARGE

const StatusCode fastly::http::StatusCode::PAYLOAD_TOO_LARGE
static

413 Payload Too Large [RFC9110, Section 15.5.14]

◆ PAYMENT_REQUIRED

const StatusCode fastly::http::StatusCode::PAYMENT_REQUIRED
static

402 Payment Required [RFC9110, Section 15.5.3]

◆ PERMANENT_REDIRECT

const StatusCode fastly::http::StatusCode::PERMANENT_REDIRECT
static

308 Permanent Redirect [RFC9110, Section 15.4.8]

◆ PRECONDITION_FAILED

const StatusCode fastly::http::StatusCode::PRECONDITION_FAILED
static

412 Precondition Failed [RFC9110, Section 15.5.13]

◆ PRECONDITION_REQUIRED

const StatusCode fastly::http::StatusCode::PRECONDITION_REQUIRED
static

428 Precondition Required [RFC6585, Section 3]

◆ PROCESSING

const StatusCode fastly::http::StatusCode::PROCESSING
static

102 Processing [RFC2518, Section 10.1]

◆ PROXY_AUTHENTICATION_REQUIRED

const StatusCode fastly::http::StatusCode::PROXY_AUTHENTICATION_REQUIRED
static

407 Proxy Authentication Required [RFC9110, Section 15.5.8]

◆ RANGE_NOT_SATISFIABLE

const StatusCode fastly::http::StatusCode::RANGE_NOT_SATISFIABLE
static

416 Range Not Satisfiable [RFC9110, Section 15.5.17]

◆ REQUEST_HEADER_FIELDS_TOO_LARGE

const StatusCode fastly::http::StatusCode::REQUEST_HEADER_FIELDS_TOO_LARGE
static

431 Request Header Fields Too Large [RFC6585, Section 5]

◆ REQUEST_TIMEOUT

const StatusCode fastly::http::StatusCode::REQUEST_TIMEOUT
static

◆ RESET_CONTENT

const StatusCode fastly::http::StatusCode::RESET_CONTENT
static

205 Reset Content [RFC9110, Section 15.3.6]

◆ SEE_OTHER

const StatusCode fastly::http::StatusCode::SEE_OTHER
static

303 See Other [RFC9110, Section 15.4.4]

◆ SERVICE_UNAVAILABLE

const StatusCode fastly::http::StatusCode::SERVICE_UNAVAILABLE
static

503 Service Unavailable [RFC9110, Section 15.6.4]

◆ SWITCHING_PROTOCOLS

const StatusCode fastly::http::StatusCode::SWITCHING_PROTOCOLS
static

101 Switching Protocols [RFC9110, Section 15.2.2]

◆ TEMPORARY_REDIRECT

const StatusCode fastly::http::StatusCode::TEMPORARY_REDIRECT
static

307 Temporary Redirect [RFC9110, Section 15.4.7]

◆ TOO_EARLY

const StatusCode fastly::http::StatusCode::TOO_EARLY
static

425 Too early [RFC8470, Section 5.2]

◆ TOO_MANY_REQUESTS

const StatusCode fastly::http::StatusCode::TOO_MANY_REQUESTS
static

429 Too Many Requests [RFC6585, Section 4]

◆ UNAUTHORIZED

const StatusCode fastly::http::StatusCode::UNAUTHORIZED
static

401 Unauthorized [RFC9110, Section 15.5.2]

◆ UNAVAILABLE_FOR_LEGAL_REASONS

const StatusCode fastly::http::StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS
static

451 Unavailable For Legal Reasons [RFC7725, Section 3]

◆ UNPROCESSABLE_ENTITY

const StatusCode fastly::http::StatusCode::UNPROCESSABLE_ENTITY
static

422 Unprocessable Entity [RFC9110, Section 15.5.21]

◆ UNSUPPORTED_MEDIA_TYPE

const StatusCode fastly::http::StatusCode::UNSUPPORTED_MEDIA_TYPE
static

415 Unsupported Media Type [RFC9110, Section 15.5.16]

◆ UPGRADE_REQUIRED

const StatusCode fastly::http::StatusCode::UPGRADE_REQUIRED
static

426 Upgrade Required [RFC9110, Section 15.5.22]

◆ URI_TOO_LONG

const StatusCode fastly::http::StatusCode::URI_TOO_LONG
static

414 URI Too Long [RFC9110, Section 15.5.15]

◆ USE_PROXY

const StatusCode fastly::http::StatusCode::USE_PROXY
static

305 Use Proxy [RFC9110, Section 15.4.6]

◆ VARIANT_ALSO_NEGOTIATES

const StatusCode fastly::http::StatusCode::VARIANT_ALSO_NEGOTIATES
static

506 Variant Also Negotiates [RFC2295, Section 8.1]


The documentation for this class was generated from the following file: