Skip to content

Repository files navigation

Http

Latest Stable VersionLicenseci.yml

HTTP Status Codes and Exceptions

Requirements

  • php: ^7.4 || ^8.0

Installing

Install the latest version with:

composer require 'corpus/http'

Documentation

Class: Corpus\Http\Exceptions\AbstractHttpException

Base Exception class all HTTP Exception Classes Extend

Method: AbstractHttpException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Method: AbstractHttpException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents

Class: Corpus\Http\Exceptions\ClientError\AbstractClientErrorException

Base of Exceptions Representing The 4xx Class

Method: AbstractClientErrorException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Method: AbstractClientErrorException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents

Class: Corpus\Http\Exceptions\ClientError\BadRequestException

Method: BadRequestException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: BadRequestException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Class: Corpus\Http\Exceptions\ClientError\ForbiddenException

Method: ForbiddenException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: ForbiddenException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Class: Corpus\Http\Exceptions\ClientError\NotFoundException

Method: NotFoundException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: NotFoundException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Class: Corpus\Http\Exceptions\ClientError\TooManyRequestsException

Method: TooManyRequestsException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: TooManyRequestsException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Class: Corpus\Http\Exceptions\ClientError\UnauthorizedException

Method: UnauthorizedException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: UnauthorizedException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Class: Corpus\Http\Exceptions\Redirection\AbstractLocationRedirectionHttpException

Base of 3xx Exceptions which include a "Location" header.

Method: AbstractLocationRedirectionHttpException->__construct

function __construct(string$location [, string$message = '' [, ?\Throwable$previous = null]])

AbstractRedirectionHttpException constructor.

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • \Throwable | null$previous - [optional] The previous throwable used for the exception chaining.

Undocumented Method: AbstractLocationRedirectionHttpException->getLocation()


Method: AbstractLocationRedirectionHttpException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents

Class: Corpus\Http\Exceptions\Redirection\AbstractRedirectionHttpException

Base of Exceptions Representing The 3xx Class

Method: AbstractRedirectionHttpException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Method: AbstractRedirectionHttpException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents

Class: Corpus\Http\Exceptions\Redirection\FoundException

Method: FoundException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: FoundException->__construct

function __construct(string$location [, string$message = '' [, ?\Throwable$previous = null]])

AbstractRedirectionHttpException constructor.

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • \Throwable | null$previous - [optional] The previous throwable used for the exception chaining.

Undocumented Method: FoundException->getLocation()

Class: Corpus\Http\Exceptions\Redirection\SeeOtherException

Method: SeeOtherException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: SeeOtherException->__construct

function __construct(string$location [, string$message = '' [, ?\Throwable$previous = null]])

AbstractRedirectionHttpException constructor.

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • \Throwable | null$previous - [optional] The previous throwable used for the exception chaining.

Undocumented Method: SeeOtherException->getLocation()

Class: Corpus\Http\Exceptions\ServerError\AbstractServerErrorException

Base of Exceptions Representing The 5xx Class

Method: AbstractServerErrorException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Method: AbstractServerErrorException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents

Class: Corpus\Http\Exceptions\ServerError\InternalServerErrorException

Method: InternalServerErrorException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: InternalServerErrorException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Class: Corpus\Http\Exceptions\Success\AbstractSuccessException

Base of Exceptions Representing The 2xx Class

Method: AbstractSuccessException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Method: AbstractSuccessException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents

Class: Corpus\Http\Exceptions\Success\NoContentException

Method: NoContentException->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents


Method: NoContentException->__construct

function __construct([ $message = '' [, ?\Throwable$previous = null]])

Construct the *HttpException.

Use the HTTP Status code as the base exceptions code.

Parameters:
  • string$message

Class: Corpus\Http\Status

<?phpnamespaceCorpus\Http;
class Status {
publicconstStatusContinue = 100;
publicconstSwitchingProtocols = 101;
publicconstProcessing = 102;
publicconstEarlyHints = 103;
publicconstOK = 200;
publicconstCreated = 201;
publicconstAccepted = 202;
publicconstNonAuthoritativeInfo = 203;
publicconstNoContent = 204;
publicconstResetContent = 205;
publicconstPartialContent = 206;
publicconstMultiStatus = 207;
publicconstAlreadyReported = 208;
publicconstIMUsed = 226;
publicconstMultipleChoices = 300;
publicconstMovedPermanently = 301;
publicconstFound = 302;
publicconstSeeOther = 303;
publicconstNotModified = 304;
publicconstUseProxy = 305;
publicconstTemporaryRedirect = 307;
publicconstPermanentRedirect = 308;
publicconstBadRequest = 400;
publicconstUnauthorized = 401;
publicconstPaymentRequired = 402;
publicconstForbidden = 403;
publicconstNotFound = 404;
publicconstMethodNotAllowed = 405;
publicconstNotAcceptable = 406;
publicconstProxyAuthRequired = 407;
publicconstRequestTimeout = 408;
publicconstConflict = 409;
publicconstGone = 410;
publicconstLengthRequired = 411;
publicconstPreconditionFailed = 412;
publicconstRequestEntityTooLarge = 413;
publicconstRequestURITooLong = 414;
publicconstUnsupportedMediaType = 415;
publicconstRequestedRangeNotSatisfiable = 416;
publicconstExpectationFailed = 417;
publicconstTeapot = 418;
publicconstMisdirectedRequest = 421;
publicconstUnprocessableEntity = 422;
publicconstLocked = 423;
publicconstFailedDependency = 424;
publicconstTooEarly = 425;
publicconstUpgradeRequired = 426;
publicconstPreconditionRequired = 428;
publicconstTooManyRequests = 429;
publicconstRequestHeaderFieldsTooLarge = 431;
publicconstUnavailableForLegalReasons = 451;
publicconstInternalServerError = 500;
publicconstNotImplemented = 501;
publicconstBadGateway = 502;
publicconstServiceUnavailable = 503;
publicconstGatewayTimeout = 504;
publicconstHTTPVersionNotSupported = 505;
publicconstVariantAlsoNegotiates = 506;
publicconstInsufficientStorage = 507;
publicconstLoopDetected = 508;
publicconstNotExtended = 510;
publicconstNetworkAuthenticationRequired = 511;
/** * @var array<int,string> */publicstatic$statusText = [self::StatusContinue => 'Continue', self::SwitchingProtocols => 'Switching Protocols', self::Processing => 'Processing', self::EarlyHints => 'Early Hints', self::OK => 'OK', self::Created => 'Created', self::Accepted => 'Accepted', self::NonAuthoritativeInfo => 'Non-Authoritative Information', self::NoContent => 'No Content', self::ResetContent => 'Reset Content', self::PartialContent => 'Partial Content', self::MultiStatus => 'Multi-Status', self::AlreadyReported => 'Already Reported', self::IMUsed => 'IM Used', self::MultipleChoices => 'Multiple Choices', self::MovedPermanently => 'Moved Permanently', self::Found => 'Found', self::SeeOther => 'See Other', self::NotModified => 'Not Modified', self::UseProxy => 'Use Proxy', self::TemporaryRedirect => 'Temporary Redirect', self::PermanentRedirect => 'Permanent Redirect', self::BadRequest => 'Bad Request', self::Unauthorized => 'Unauthorized', self::PaymentRequired => 'Payment Required', self::Forbidden => 'Forbidden', self::NotFound => 'Not Found', self::MethodNotAllowed => 'Method Not Allowed', self::NotAcceptable => 'Not Acceptable', self::ProxyAuthRequired => 'Proxy Authentication Required', self::RequestTimeout => 'Request Timeout', self::Conflict => 'Conflict', self::Gone => 'Gone', self::LengthRequired => 'Length Required', self::PreconditionFailed => 'Precondition Failed', self::RequestEntityTooLarge => 'Request Entity Too Large', self::RequestURITooLong => 'Request URI Too Long', self::UnsupportedMediaType => 'Unsupported Media Type', self::RequestedRangeNotSatisfiable => 'Requested Range Not Satisfiable', self::ExpectationFailed => 'Expectation Failed', self::Teapot => 'I\'m a teapot', self::MisdirectedRequest => 'Misdirected Request', self::UnprocessableEntity => 'Unprocessable Entity', self::Locked => 'Locked', self::FailedDependency => 'Failed Dependency', self::TooEarly => 'Too Early', self::UpgradeRequired => 'Upgrade Required', self::PreconditionRequired => 'Precondition Required', self::TooManyRequests => 'Too Many Requests', self::RequestHeaderFieldsTooLarge => 'Request Header Fields Too Large', self::UnavailableForLegalReasons => 'Unavailable For Legal Reasons', self::InternalServerError => 'Internal Server Error', self::NotImplemented => 'Not Implemented', self::BadGateway => 'Bad Gateway', self::ServiceUnavailable => 'Service Unavailable', self::GatewayTimeout => 'Gateway Timeout', self::HTTPVersionNotSupported => 'HTTP Version Not Supported', self::VariantAlsoNegotiates => 'Variant Also Negotiates', self::InsufficientStorage => 'Insufficient Storage', self::LoopDetected => 'Loop Detected', self::NotExtended => 'Not Extended', self::NetworkAuthenticationRequired => 'Network Authentication Required'];
}

Method: Status::statusText

function statusText(int$code) : ?string

Return the text for an HTTP status code.

Class: Corpus\Http\StatusAwareInterface

Method: StatusAwareInterface->getHttpStatusCode

function getHttpStatusCode() : int

Get the HTTP Status Code the Exception Represents

About

HTTP Status Codes and Exceptions

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages