StatusCode

Classin httpcompute-sdk-cpp 0.7.0View source

Include fastly/http/status_code.h to use this class.

Constructor

Overload 1 of 2

fastly::http::StatusCode::StatusCode() = default
View source

Overload 2 of 2

constexpr constexpr fastly::http::StatusCode::StatusCode(uint16_t code)
View source

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

Parameters

code: uint16_t

Constants

CONTINUE

const StatusCoderead-onlyView source

SWITCHING_PROTOCOLS

const StatusCoderead-onlyView source

101 Switching Protocols RFC9110, Section 15.2.2

PROCESSING

const StatusCoderead-onlyView source

102 Processing RFC2518, Section 10.1

CREATED

const StatusCoderead-onlyView source

ACCEPTED

const StatusCoderead-onlyView source

NON_AUTHORITATIVE_INFORMATION

const StatusCoderead-onlyView source

203 Non-Authoritative Information RFC9110, Section 15.3.4

NO_CONTENT

const StatusCoderead-onlyView source

RESET_CONTENT

const StatusCoderead-onlyView source

205 Reset Content RFC9110, Section 15.3.6

PARTIAL_CONTENT

const StatusCoderead-onlyView source

206 Partial Content RFC9110, Section 15.3.7

MULTI_STATUS

const StatusCoderead-onlyView source

207 Multi-Status RFC4918, Section 11.1

ALREADY_REPORTED

const StatusCoderead-onlyView source

208 Already Reported RFC5842, Section 7.1

IM_USED

const StatusCoderead-onlyView source

MULTIPLE_CHOICES

const StatusCoderead-onlyView source

300 Multiple Choices RFC9110, Section 15.4.1

MOVED_PERMANENTLY

const StatusCoderead-onlyView source

301 Moved Permanently RFC9110, Section 15.4.2

FOUND

const StatusCoderead-onlyView source

SEE_OTHER

const StatusCoderead-onlyView source

NOT_MODIFIED

const StatusCoderead-onlyView source

304 Not Modified RFC9110, Section 15.4.5

USE_PROXY

const StatusCoderead-onlyView source

TEMPORARY_REDIRECT

const StatusCoderead-onlyView source

307 Temporary Redirect RFC9110, Section 15.4.7

PERMANENT_REDIRECT

const StatusCoderead-onlyView source

308 Permanent Redirect RFC9110, Section 15.4.8

BAD_REQUEST

const StatusCoderead-onlyView source

UNAUTHORIZED

const StatusCoderead-onlyView source

401 Unauthorized RFC9110, Section 15.5.2

PAYMENT_REQUIRED

const StatusCoderead-onlyView source

402 Payment Required RFC9110, Section 15.5.3

FORBIDDEN

const StatusCoderead-onlyView source

NOT_FOUND

const StatusCoderead-onlyView source

METHOD_NOT_ALLOWED

const StatusCoderead-onlyView source

405 Method Not Allowed RFC9110, Section 15.5.6

NOT_ACCEPTABLE

const StatusCoderead-onlyView source

406 Not Acceptable RFC9110, Section 15.5.7

PROXY_AUTHENTICATION_REQUIRED

const StatusCoderead-onlyView source

407 Proxy Authentication Required RFC9110, Section 15.5.8

REQUEST_TIMEOUT

const StatusCoderead-onlyView source

CONFLICT

const StatusCoderead-onlyView source

LENGTH_REQUIRED

const StatusCoderead-onlyView source

411 Length Required RFC9110, Section 15.5.12

PRECONDITION_FAILED

const StatusCoderead-onlyView source

412 Precondition Failed RFC9110, Section 15.5.13

PAYLOAD_TOO_LARGE

const StatusCoderead-onlyView source

413 Payload Too Large RFC9110, Section 15.5.14

URI_TOO_LONG

const StatusCoderead-onlyView source

414 URI Too Long RFC9110, Section 15.5.15

UNSUPPORTED_MEDIA_TYPE

const StatusCoderead-onlyView source

415 Unsupported Media Type RFC9110, Section 15.5.16

RANGE_NOT_SATISFIABLE

const StatusCoderead-onlyView source

416 Range Not Satisfiable RFC9110, Section 15.5.17

EXPECTATION_FAILED

const StatusCoderead-onlyView source

417 Expectation Failed RFC9110, Section 15.5.18

IM_A_TEAPOT

const StatusCoderead-onlyView source

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

MISDIRECTED_REQUEST

const StatusCoderead-onlyView source

UNPROCESSABLE_ENTITY

const StatusCoderead-onlyView source

422 Unprocessable Entity RFC9110, Section 15.5.21

LOCKED

const StatusCoderead-onlyView source

FAILED_DEPENDENCY

const StatusCoderead-onlyView source

424 Failed Dependency RFC4918, Section 11.4

TOO_EARLY

const StatusCoderead-onlyView source

425 Too early RFC8470, Section 5.2

UPGRADE_REQUIRED

const StatusCoderead-onlyView source

426 Upgrade Required RFC9110, Section 15.5.22

PRECONDITION_REQUIRED

const StatusCoderead-onlyView source

428 Precondition Required RFC6585, Section 3

TOO_MANY_REQUESTS

const StatusCoderead-onlyView source

429 Too Many Requests RFC6585, Section 4

REQUEST_HEADER_FIELDS_TOO_LARGE

const StatusCoderead-onlyView source

431 Request Header Fields Too Large RFC6585, Section 5

const StatusCoderead-onlyView source

451 Unavailable For Legal Reasons RFC7725, Section 3

INTERNAL_SERVER_ERROR

const StatusCoderead-onlyView source

500 Internal Server Error RFC9110, Section 15.6.1

NOT_IMPLEMENTED

const StatusCoderead-onlyView source

501 Not Implemented RFC9110, Section 15.6.2

BAD_GATEWAY

const StatusCoderead-onlyView source

502 Bad Gateway RFC9110, Section 15.6.3

SERVICE_UNAVAILABLE

const StatusCoderead-onlyView source

503 Service Unavailable RFC9110, Section 15.6.4

GATEWAY_TIMEOUT

const StatusCoderead-onlyView source

504 Gateway Timeout RFC9110, Section 15.6.5

HTTP_VERSION_NOT_SUPPORTED

const StatusCoderead-onlyView source

505 HTTP Version Not Supported RFC9110, Section 15.6.6

VARIANT_ALSO_NEGOTIATES

const StatusCoderead-onlyView source

506 Variant Also Negotiates RFC2295, Section 8.1

INSUFFICIENT_STORAGE

const StatusCoderead-onlyView source

507 Insufficient Storage RFC4918, Section 11.5

LOOP_DETECTED

const StatusCoderead-onlyView source

508 Loop Detected RFC5842, Section 7.2

NOT_EXTENDED

const StatusCoderead-onlyView source

510 Not Extended RFC2774, Section 7

NETWORK_AUTHENTICATION_REQUIRED

const StatusCoderead-onlyView source

511 Network Authentication Required RFC6585, Section 6

Methods

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

Returns the uint16_t corresponding to this StatusCode.

Returns

canonical_reason

View source
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

Returns

tl::expected<std::optional<std::string>, fastly::FastlyError>
auto status{fastly::http::StatusCode::OK};
assert(status.canonical_reason() == std::optional("OK"s)));

from_code

View source
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.

Parameters

code: uint16_t

Returns

std::optional<StatusCode>

is_client_error

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

Check if status is within 400-499.

Returns

bool

is_informational

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

Check if status is within 100-199.

Returns

bool

is_redirection

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

Check if status is within 300-399.

Returns

bool

is_server_error

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

Check if status is within 500-599.

Returns

bool

is_success

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

Check if status is within 200-299.

Returns

bool

operator bool

View source
explicit fastly::http::StatusCode::operator bool() const = delete

operator!=

View source
constexpr constexpr bool fastly::http::StatusCode::operator!=(StatusCode a) const

Parameters

a: StatusCode

Returns

constexpr bool

operator==

View source
constexpr constexpr bool fastly::http::StatusCode::operator==(StatusCode a) const

Parameters

a: StatusCode

Returns

constexpr bool