From f6c6b45731c9f8485d97c8b0b616fd6b99dfa52f Mon Sep 17 00:00:00 2001 From: Mihail Binev Date: Tue, 14 Apr 2020 13:33:06 +0200 Subject: [PATCH 1/3] adds "ext-fileinfo" --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7ede91e..1b490c2 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "psr/http-client": "~1", "koded/stdlib": "~4", "ext-json": "*", - "ext-curl": "*" + "ext-curl": "*", + "ext-fileinfo": "*" }, "autoload": { "psr-4": { From 4ba9a9034be37dd93c2dc74f3334afa3a837d553 Mon Sep 17 00:00:00 2001 From: Mihail Binev Date: Tue, 14 Apr 2020 13:37:06 +0200 Subject: [PATCH 2/3] Moves HTTP status codes into interface --- AcceptHeaderNegotiator.php | 5 +- Client/CurlClient.php | 12 +-- Client/EncodingTrait.php | 5 +- Client/PhpClient.php | 10 +- Client/Psr18ClientTrait.php | 5 +- ClientRequest.php | 6 +- HeaderTrait.php | 9 +- Interfaces.php | 176 ++++++++++++++++++++++++++++++- ServerResponse.php | 8 +- StatusCode.php | 203 ++++-------------------------------- Stream.php | 3 +- Tests/StatusCodeTest.php | 5 +- Uri.php | 3 +- VERSION | 2 +- diagrams/interfaces.png | Bin 13747 -> 14152 bytes 15 files changed, 232 insertions(+), 220 deletions(-) diff --git a/AcceptHeaderNegotiator.php b/AcceptHeaderNegotiator.php index 83796c2..e4b9694 100644 --- a/AcceptHeaderNegotiator.php +++ b/AcceptHeaderNegotiator.php @@ -27,6 +27,7 @@ use Generator; use InvalidArgumentException; +use Koded\Http\Interfaces\HttpStatus; class AcceptHeaderNegotiator { @@ -101,7 +102,7 @@ public function __construct(string $header) if (!empty($type) && !preg_match('~^(\*|[a-z0-9._]+)([/|_-])?(\*|[a-z0-9.\-_+]+)?$~i', $type, $matches)) { throw new InvalidArgumentException(sprintf('"%s" is not a valid Access header', $header), - StatusCode::NOT_ACCEPTABLE); + HttpStatus::NOT_ACCEPTABLE); } $this->separator = $matches[2] ?? '/'; @@ -110,7 +111,7 @@ public function __construct(string $header) if ('*' === $type && '*' !== $subtype) { // @see https://tools.ietf.org/html/rfc7231#section-5.3.2 throw new InvalidArgumentException(sprintf('"%s" is not a valid Access header', $header), - StatusCode::NOT_ACCEPTABLE); + HttpStatus::NOT_ACCEPTABLE); } // @see https://tools.ietf.org/html/rfc7540#section-8.1.2 diff --git a/Client/CurlClient.php b/Client/CurlClient.php index 9041003..764aff5 100644 --- a/Client/CurlClient.php +++ b/Client/CurlClient.php @@ -12,8 +12,8 @@ namespace Koded\Http\Client; -use Koded\Http\{ClientRequest, ServerResponse, StatusCode}; -use Koded\Http\Interfaces\{HttpRequestClient, Response}; +use Koded\Http\{ClientRequest, ServerResponse}; +use Koded\Http\Interfaces\{HttpRequestClient, HttpStatus, Response}; use Throwable; use function Koded\Http\create_stream; use function Koded\Stdlib\json_serialize; @@ -59,14 +59,14 @@ public function read(): Response if (false === $resource = $this->createResource()) { return new ServerResponse( 'The HTTP client is not created therefore cannot read anything', - StatusCode::PRECONDITION_FAILED); + HttpStatus::PRECONDITION_FAILED); } curl_setopt_array($resource, $this->options); $response = curl_exec($resource); if (true === $this->hasError($resource)) { - return (new ServerResponse($this->getCurlError($resource), StatusCode::FAILED_DEPENDENCY)) + return (new ServerResponse($this->getCurlError($resource), HttpStatus::FAILED_DEPENDENCY)) ->withHeader('Content-Type', 'application/json'); } @@ -76,7 +76,7 @@ public function read(): Response $this->responseHeaders ); } catch (Throwable $e) { - return new ServerResponse($e->getMessage(), StatusCode::INTERNAL_SERVER_ERROR); + return new ServerResponse($e->getMessage(), HttpStatus::INTERNAL_SERVER_ERROR); } finally { unset($response); @@ -193,7 +193,7 @@ protected function getCurlError($resource): string 'uri' => curl_getinfo($resource, CURLINFO_EFFECTIVE_URL), 'message' => curl_strerror(curl_errno($resource)), 'explain' => curl_error($resource), - 'code' => StatusCode::FAILED_DEPENDENCY, + 'code' => HttpStatus::FAILED_DEPENDENCY, ]); } diff --git a/Client/EncodingTrait.php b/Client/EncodingTrait.php index 22d57f8..fd59b43 100644 --- a/Client/EncodingTrait.php +++ b/Client/EncodingTrait.php @@ -13,8 +13,7 @@ namespace Koded\Http\Client; use Exception; -use Koded\Http\Interfaces\HttpRequestClient; -use Koded\Http\StatusCode; +use Koded\Http\Interfaces\{HttpRequestClient, HttpStatus}; use Psr\Http\Client\ClientExceptionInterface; @@ -32,7 +31,7 @@ public function withEncoding(int $type): HttpRequestClient throw new class( 'Invalid encoding type. Expects 0, PHP_QUERY_RFC1738 or PHP_QUERY_RFC3986', - StatusCode::BAD_REQUEST + HttpStatus::BAD_REQUEST ) extends Exception implements ClientExceptionInterface {}; } } diff --git a/Client/PhpClient.php b/Client/PhpClient.php index 47557e9..60f2b4f 100644 --- a/Client/PhpClient.php +++ b/Client/PhpClient.php @@ -12,8 +12,8 @@ namespace Koded\Http\Client; -use Koded\Http\{ClientRequest, ServerResponse, StatusCode}; -use Koded\Http\Interfaces\{HttpRequestClient, Response}; +use Koded\Http\{ClientRequest, ServerResponse}; +use Koded\Http\Interfaces\{HttpRequestClient, HttpStatus, Response}; use Throwable; use function Koded\Http\create_stream; @@ -56,7 +56,7 @@ public function read(): Response try { if (false === $resource = $this->createResource(stream_context_create(['http' => $this->options]))) { - return new ServerResponse(error_get_last()['message'], StatusCode::FAILED_DEPENDENCY); + return new ServerResponse(error_get_last()['message'], HttpStatus::FAILED_DEPENDENCY); } $this->extractFromResponseHeaders($resource, $headers, $statusCode); @@ -67,7 +67,7 @@ public function read(): Response $headers ); } catch (Throwable $e) { - return new ServerResponse($e->getMessage(), StatusCode::INTERNAL_SERVER_ERROR); + return new ServerResponse($e->getMessage(), HttpStatus::INTERNAL_SERVER_ERROR); } finally { if (is_resource($resource)) { fclose($resource); @@ -174,7 +174,7 @@ protected function extractFromResponseHeaders($response, &$headers, &$statusCode return false !== stripos($header, 'HTTP/', 0); }); $statusCode = array_pop($statusCode) ?: 'HTTP/1.1 200 OK'; - $statusCode = (int)(explode(' ', $statusCode)[1] ?? StatusCode::OK); + $statusCode = (int)(explode(' ', $statusCode)[1] ?? HttpStatus::OK); foreach ($_headers as $header) { [$k, $v] = explode(':', $header, 2) + [1 => null]; diff --git a/Client/Psr18ClientTrait.php b/Client/Psr18ClientTrait.php index c9f93be..f1675f2 100644 --- a/Client/Psr18ClientTrait.php +++ b/Client/Psr18ClientTrait.php @@ -13,8 +13,7 @@ namespace Koded\Http\Client; use Exception; -use Koded\Http\Interfaces\Response; -use Koded\Http\StatusCode; +use Koded\Http\Interfaces\{HttpStatus, Response}; use Psr\Http\Client\{NetworkExceptionInterface, RequestExceptionInterface}; use Psr\Http\Message\{RequestInterface, ResponseInterface}; @@ -40,7 +39,7 @@ public function sendRequest(RequestInterface $request): ResponseInterface ->withBody($request->getBody()) ->read(); - if ($response->getStatusCode() >= StatusCode::BAD_REQUEST) { + if ($response->getStatusCode() >= HttpStatus::BAD_REQUEST) { throw new Psr18Exception($response->getBody()->getContents(), $response->getStatusCode(), $this); } diff --git a/ClientRequest.php b/ClientRequest.php index f5054eb..207d2ec 100644 --- a/ClientRequest.php +++ b/ClientRequest.php @@ -14,7 +14,7 @@ use InvalidArgumentException; use JsonSerializable; -use Koded\Http\Interfaces\Request; +use Koded\Http\Interfaces\{HttpStatus, Request}; use Psr\Http\Message\{RequestInterface, UriInterface}; use function Koded\Stdlib\json_serialize; @@ -107,7 +107,7 @@ public function getRequestTarget(): string public function withRequestTarget($requestTarget): ClientRequest { if (preg_match('/\s+/', $requestTarget)) { - throw new InvalidArgumentException(self::E_INVALID_REQUEST_TARGET, StatusCode::BAD_REQUEST); + throw new InvalidArgumentException(self::E_INVALID_REQUEST_TARGET, HttpStatus::BAD_REQUEST); } $instance = clone $this; @@ -172,7 +172,7 @@ protected function setMethod(string $method, RequestInterface $instance): Reques protected function assertSafeMethod(): ?ServerResponse { if ($this->isSafeMethod() && $this->getBody()->getSize() > 0) { - return new ServerResponse(self::E_SAFE_METHODS_WITH_BODY, StatusCode::BAD_REQUEST); + return new ServerResponse(self::E_SAFE_METHODS_WITH_BODY, HttpStatus::BAD_REQUEST); } return null; diff --git a/HeaderTrait.php b/HeaderTrait.php index 9ad3379..3c2e929 100644 --- a/HeaderTrait.php +++ b/HeaderTrait.php @@ -13,6 +13,7 @@ namespace Koded\Http; use InvalidArgumentException; +use Koded\Http\Interfaces\HttpStatus; use Throwable; @@ -198,12 +199,12 @@ protected function normalizeHeaderName($name): string $name = str_replace(["\r", "\n", "\t"], '', trim($name)); } catch (Throwable $e) { throw new InvalidArgumentException( - sprintf('Header name must be a string, %s given', gettype($name)), StatusCode::BAD_REQUEST + sprintf('Header name must be a string, %s given', gettype($name)), HttpStatus::BAD_REQUEST ); } if ('' === $name) { - throw new InvalidArgumentException('Empty header name', StatusCode::BAD_REQUEST); + throw new InvalidArgumentException('Empty header name', HttpStatus::BAD_REQUEST); } return $name; @@ -227,7 +228,7 @@ protected function normalizeHeaderValue(string $name, $value): array break; default: throw new InvalidArgumentException( - sprintf('Invalid header value, expects string or array, "%s" given', $type), StatusCode::BAD_REQUEST + sprintf('Invalid header value, expects string or array, "%s" given', $type), HttpStatus::BAD_REQUEST ); } @@ -235,7 +236,7 @@ protected function normalizeHeaderValue(string $name, $value): array return trim(preg_replace('/\s+/', ' ', $v)); }, $value))) { throw new InvalidArgumentException( - sprintf('The value for header "%s" cannot be empty', $name), StatusCode::BAD_REQUEST + sprintf('The value for header "%s" cannot be empty', $name), HttpStatus::BAD_REQUEST ); } diff --git a/Interfaces.php b/Interfaces.php index 9967e57..40f0ba6 100644 --- a/Interfaces.php +++ b/Interfaces.php @@ -129,7 +129,7 @@ public function getContentType(): string; interface HttpRequestClient extends RequestInterface, ExtendedMessageInterface, ClientInterface { - const USER_AGENT = 'Koded/HttpClient (+https://github.com/kodedphp/http)'; + const USER_AGENT = 'Koded/HttpClient (+https://github.com/kodedphp/http)'; const X_WWW_FORM_URLENCODED = 'application/x-www-form-urlencoded'; /** @@ -301,3 +301,177 @@ interface ValidatableRequest */ public function validate(HttpInputValidator $validator): ?Response; } + + +interface HttpStatus +{ + const CODE = [ + // Informational 1xx + 100 => 'Continue', + 101 => 'Switching Protocols', + 102 => 'Processing', + // 103-199 Unassigned + + // Success 2xx + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 207 => 'Multi-Status', + 208 => 'Already Reported', + // 209-225 Unassigned + 226 => 'IM Used', + // 227-299 Unassigned + + // Redirection 3xx + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + // 306 is deprecated and reserved + 307 => 'Temporary Redirect', + 308 => 'Permanent Redirect', + // 309-399 Unassigned + + // Client Error 4xx + 400 => 'Bad Request', + 401 => 'Unauthorized', // Really means "Unauthenticated" + 402 => 'Payment Required', + 403 => 'Forbidden', // Really means "Unauthorized" + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Payload Too Large', + 414 => 'URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Range Not Satisfiable', + 417 => 'Expectation Failed', + 418 => "I'm teapot", + // 418-420 Unassigned + 421 => 'Misdirected Request', + 422 => 'Unprocessable Entity', + 423 => 'Locked', + 424 => 'Failed Dependency', + 425 => 'Unordered Collection', + 426 => 'Upgrade Required', + 428 => 'Precondition Required', + 429 => 'Too Many Requests', + // 430 Unassigned + 431 => 'Request Header Fields Too Large', + // 432-499 Unassigned + + // Server Error 5xx + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported', + 506 => 'Variant Also Negotiates', + 507 => 'Insufficient Storage', + 508 => 'Loop Detected', + 509 => 'Bandwidth Limit Exceeded', + 510 => 'Not Extended', + 511 => 'Network Authentication Required', + // 512-599 Unassigned + + 596 => 'Service Not Found', + ]; + + // Informational 1xx + const CONTINUE = 100; + const SWITCHING_PROTOCOLS = 101; + const PROCESSING = 102; + // 103-199 Unassigned + + // Success 2xx + const OK = 200; + const CREATED = 201; + const ACCEPTED = 202; + const NON_AUTHORITATIVE_INFORMATION = 203; + const NO_CONTENT = 204; + const RESET_CONTENT = 205; + const PARTIAL_CONTENT = 206; + const MULTI_STATUS = 207; + const ALREADY_REPORTED = 208; + // 209-225 Unassigned + const IM_USED = 226; + // 227-299 Unassigned + + // Redirection 3xx + const MULTIPLE_CHOICES = 300; + const MOVED_PERMANENTLY = 301; + const FOUND = 302; + const SEE_OTHER = 303; + const NOT_MODIFIED = 304; + const USE_PROXY = 305; + // 306 is deprecated and reserved + const TEMPORARY_REDIRECT = 307; + const PERMANENT_REDIRECT = 308; + // 309-399 Unassigned + + // Client Error 4xx + const BAD_REQUEST = 400; + const UNAUTHORIZED = 401; + const PAYMENT_REQUIRED = 402; + const FORBIDDEN = 403; + const NOT_FOUND = 404; + const METHOD_NOT_ALLOWED = 405; + const NOT_ACCEPTABLE = 406; + const PROXY_AUTHENTICATION_REQUIRED = 407; + const REQUEST_TIMEOUT = 408; + const CONFLICT = 409; + const GONE = 410; + const LENGTH_REQUIRED = 411; + const PRECONDITION_FAILED = 412; + const PAYLOAD_TOO_LARGE = 413; + const REQUEST_URI_TOO_LONG = 414; + const UNSUPPORTED_MEDIA_TYPE = 415; + const RANGE_NOT_SATISFIABLE = 416; + const EXPECTATION_FAILED = 417; + const I_AM_TEAPOT = 418; + // 418-420 Unassigned + const MISDIRECTED_REQUEST = 421; + const UNPROCESSABLE_ENTITY = 422; + const LOCKED = 423; + const FAILED_DEPENDENCY = 424; + const UNORDERED_COLLECTION = 425; + const UPGRADE_REQUIRED = 426; + const PRECONDITION_REQUIRED = 428; + const TOO_MANY_REQUESTS = 429; + // 430 Unassigned + const REQUEST_HEADER_FIELDS_TOO_LARGE = 431; + // 432-499 Unassigned, unless defined + + const UNAVAILABLE_FOR_LEGAL_REASONS = 451; + + // Server Error 5xx + const INTERNAL_SERVER_ERROR = 500; + const NOT_IMPLEMENTED = 501; + const BAD_GATEWAY = 502; + const SERVICE_UNAVAILABLE = 503; + const GATEWAY_TIMEOUT = 504; + const VERSION_NOT_SUPPORTED = 505; + const VARIANT_ALSO_NEGOTIATES = 506; + const INSUFFICIENT_STORAGE = 507; + const LOOP_DETECTED = 508; + const BANDWIDTH_LIMIT_EXCEEDED = 509; + const NOT_EXTENDED = 510; + const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; + // 512-599 Unassigned + + const SERVICE_NOT_FOUND = 596; + + public static function description(int $code): string; +} diff --git a/ServerResponse.php b/ServerResponse.php index 43c6469..1f8f2dc 100644 --- a/ServerResponse.php +++ b/ServerResponse.php @@ -14,7 +14,7 @@ use InvalidArgumentException; use JsonSerializable; -use Koded\Http\Interfaces\{Request, Response}; +use Koded\Http\Interfaces\{HttpStatus, Request, Response}; /** * Class ServerResponse @@ -27,7 +27,7 @@ class ServerResponse implements Response, JsonSerializable private const E_CLIENT_RESPONSE_SEND = 'Cannot send the client response.'; private const E_INVALID_STATUS_CODE = 'Invalid status code %s, expected range between [100-599]'; - protected $statusCode = StatusCode::OK; + protected $statusCode = HttpStatus::OK; protected $reasonPhrase = 'OK'; /** @@ -37,7 +37,7 @@ class ServerResponse implements Response, JsonSerializable * @param int $statusCode [optional] * @param array $headers [optional] */ - public function __construct($content = '', int $statusCode = StatusCode::OK, array $headers = []) + public function __construct($content = '', int $statusCode = HttpStatus::OK, array $headers = []) { $this->setStatus($this, $statusCode); $this->setHeaders($headers); @@ -89,7 +89,7 @@ protected function setStatus(ServerResponse $instance, int $statusCode, string $ { if ($statusCode < 100 || $statusCode > 599) { throw new InvalidArgumentException( - sprintf(self::E_INVALID_STATUS_CODE, $statusCode), StatusCode::UNPROCESSABLE_ENTITY + sprintf(self::E_INVALID_STATUS_CODE, $statusCode), HttpStatus::UNPROCESSABLE_ENTITY ); } diff --git a/StatusCode.php b/StatusCode.php index 7d6476a..2d89b95 100644 --- a/StatusCode.php +++ b/StatusCode.php @@ -12,184 +12,16 @@ namespace Koded\Http; +use Exception; +use Koded\Http\Interfaces\HttpStatus; + /** * Holds HTTP status codes with their text. * * @link https://httpstatuses.com */ -class StatusCode +class StatusCode implements HttpStatus { - - const CODE = [ - - // Informational 1xx - 100 => 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', - // 103-199 Unassigned - - // Success 2xx - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-Status', - 208 => 'Already Reported', - // 209-225 Unassigned - 226 => 'IM Used', - // 227-299 Unassigned - - // Redirection 3xx - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - // 306 is deprecated and reserved - 307 => 'Temporary Redirect', - 308 => 'Permanent Redirect', - // 309-399 Unassigned - - // Client Error 4xx - 400 => 'Bad Request', - 401 => 'Unauthorized', // Really means "Unauthenticated" - 402 => 'Payment Required', - 403 => 'Forbidden', // Really means "Unauthorized" - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Payload Too Large', - 414 => 'URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Range Not Satisfiable', - 417 => 'Expectation Failed', - 418 => "I'm teapot", - // 418-420 Unassigned - 421 => 'Misdirected Request', - 422 => 'Unprocessable Entity', - 423 => 'Locked', - 424 => 'Failed Dependency', - 425 => 'Unordered Collection', - 426 => 'Upgrade Required', - 428 => 'Precondition Required', - 429 => 'Too Many Requests', - // 430 Unassigned - 431 => 'Request Header Fields Too Large', - // 432-499 Unassigned - - // Server Error 5xx - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 506 => 'Variant Also Negotiates', - 507 => 'Insufficient Storage', - 508 => 'Loop Detected', - 509 => 'Bandwidth Limit Exceeded', - 510 => 'Not Extended', - 511 => 'Network Authentication Required', - // 512-599 Unassigned - - 596 => 'Service Not Found', - ]; - - // Informational 1xx - const CONTINUE = 100; - const SWITCHING_PROTOCOLS = 101; - const PROCESSING = 102; - // 103-199 Unassigned - - // Success 2xx - const OK = 200; - const CREATED = 201; - const ACCEPTED = 202; - const NON_AUTHORITATIVE_INFORMATION = 203; - const NO_CONTENT = 204; - const RESET_CONTENT = 205; - const PARTIAL_CONTENT = 206; - const MULTI_STATUS = 207; - const ALREADY_REPORTED = 208; - // 209-225 Unassigned - const IM_USED = 226; - // 227-299 Unassigned - - // Redirection 3xx - const MULTIPLE_CHOICES = 300; - const MOVED_PERMANENTLY = 301; - const FOUND = 302; - const SEE_OTHER = 303; - const NOT_MODIFIED = 304; - const USE_PROXY = 305; - // 306 is deprecated and reserved - const TEMPORARY_REDIRECT = 307; - const PERMANENT_REDIRECT = 308; - // 309-399 Unassigned - - // Client Error 4xx - const BAD_REQUEST = 400; - const UNAUTHORIZED = 401; - const PAYMENT_REQUIRED = 402; - const FORBIDDEN = 403; - const NOT_FOUND = 404; - const METHOD_NOT_ALLOWED = 405; - const NOT_ACCEPTABLE = 406; - const PROXY_AUTHENTICATION_REQUIRED = 407; - const REQUEST_TIMEOUT = 408; - const CONFLICT = 409; - const GONE = 410; - const LENGTH_REQUIRED = 411; - const PRECONDITION_FAILED = 412; - const PAYLOAD_TOO_LARGE = 413; - const REQUEST_URI_TOO_LONG = 414; - const UNSUPPORTED_MEDIA_TYPE = 415; - const RANGE_NOT_SATISFIABLE = 416; - const EXPECTATION_FAILED = 417; - const I_AM_TEAPOT = 418; - // 418-420 Unassigned - const MISDIRECTED_REQUEST = 421; - const UNPROCESSABLE_ENTITY = 422; - const LOCKED = 423; - const FAILED_DEPENDENCY = 424; - const UNORDERED_COLLECTION = 425; - const UPGRADE_REQUIRED = 426; - const PRECONDITION_REQUIRED = 428; - const TOO_MANY_REQUESTS = 429; - // 430 Unassigned - const REQUEST_HEADER_FIELDS_TOO_LARGE = 431; - // 432-499 Unassigned, unless defined - - const UNAVAILABLE_FOR_LEGAL_REASONS = 451; - - // Server Error 5xx - const INTERNAL_SERVER_ERROR = 500; - const NOT_IMPLEMENTED = 501; - const BAD_GATEWAY = 502; - const SERVICE_UNAVAILABLE = 503; - const GATEWAY_TIMEOUT = 504; - const VERSION_NOT_SUPPORTED = 505; - const VARIANT_ALSO_NEGOTIATES = 506; - const INSUFFICIENT_STORAGE = 507; - const LOOP_DETECTED = 508; - const BANDWIDTH_LIMIT_EXCEEDED = 509; - const NOT_EXTENDED = 510; - const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; - // 512-599 Unassigned - - const SERVICE_NOT_FOUND = 596; - - /** * @param int $code * @@ -199,6 +31,7 @@ public static function description(int $code): string { return [ // 4xx + self::BAD_REQUEST => 'The response means that server cannot understand the request due to invalid syntax', self::UNAUTHORIZED => 'The request has not been applied because it lacks valid authentication credentials for the target resource', self::FORBIDDEN => 'Client does not have access rights to the content, so the server refuses to authorize it', @@ -225,18 +58,20 @@ public static function description(int $code): string self::TOO_MANY_REQUESTS => 'The user has sent too many requests in a given amount of time ("rate limiting")', self::REQUEST_HEADER_FIELDS_TOO_LARGE => 'The server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields', self::UNAVAILABLE_FOR_LEGAL_REASONS => 'The server is denying access to the resource as a consequence of a legal demand', + // 5xx - self::INTERNAL_SERVER_ERROR => 'The server encountered an unexpected condition that prevented it from fulfilling the request', - self::NOT_IMPLEMENTED => 'The server does not support the functionality required to fulfill the request', - self::BAD_GATEWAY => 'The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request', - self::SERVICE_UNAVAILABLE => 'The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay', - self::GATEWAY_TIMEOUT => 'The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request', - self::VERSION_NOT_SUPPORTED => 'The server does not support, or refuses to support, the major version of HTTP that was used in the request message', - self::VARIANT_ALSO_NEGOTIATES => 'The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process', - self::INSUFFICIENT_STORAGE => 'The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request', - self::LOOP_DETECTED => 'The server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". This status indicates that the entire operation failed', - self::BANDWIDTH_LIMIT_EXCEEDED => 'Not part of the HTTP standard. It is issued when the servers bandwidth limits have been exceeded', - self::NOT_EXTENDED => 'The policy for accessing the resource has not been met in the request. The server should send back all the information necessary for the client to issue an extended request', + + self::INTERNAL_SERVER_ERROR => 'The server encountered an unexpected condition that prevented it from fulfilling the request', + self::NOT_IMPLEMENTED => 'The server does not support the functionality required to fulfill the request', + self::BAD_GATEWAY => 'The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request', + self::SERVICE_UNAVAILABLE => 'The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay', + self::GATEWAY_TIMEOUT => 'The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request', + self::VERSION_NOT_SUPPORTED => 'The server does not support, or refuses to support, the major version of HTTP that was used in the request message', + self::VARIANT_ALSO_NEGOTIATES => 'The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process', + self::INSUFFICIENT_STORAGE => 'The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request', + self::LOOP_DETECTED => 'The server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". This status indicates that the entire operation failed', + self::BANDWIDTH_LIMIT_EXCEEDED => 'Not part of the HTTP standard. It is issued when the servers bandwidth limits have been exceeded', + self::NOT_EXTENDED => 'The policy for accessing the resource has not been met in the request. The server should send back all the information necessary for the client to issue an extended request', self::HTTP_NETWORK_AUTHENTICATION_REQUIRED => 'The client needs to authenticate to gain network access', @@ -258,7 +93,7 @@ public static function __callStatic(string $code, $withCode): ?string $status = constant("self::$code"); return ($withCode[0] ? $status . ' ' : '') . self::CODE[$status]; - } catch (\Exception $e) { + } catch (Exception $e) { return null; } } diff --git a/Stream.php b/Stream.php index be52053..4897792 100644 --- a/Stream.php +++ b/Stream.php @@ -12,6 +12,7 @@ namespace Koded\Http; +use Koded\Http\Interfaces\HttpStatus; use Psr\Http\Message\StreamInterface; use RuntimeException; use Throwable; @@ -45,7 +46,7 @@ public function __construct($stream) if (false === is_resource($stream) || 'stream' !== get_resource_type($stream)) { throw new RuntimeException( 'The provided resource is not a valid stream resource, ' . gettype($stream) . ' given.', - StatusCode::UNPROCESSABLE_ENTITY + HttpStatus::UNPROCESSABLE_ENTITY ); } diff --git a/Tests/StatusCodeTest.php b/Tests/StatusCodeTest.php index 6d44204..a662f8f 100644 --- a/Tests/StatusCodeTest.php +++ b/Tests/StatusCodeTest.php @@ -2,6 +2,7 @@ namespace Koded\Http; +use Koded\Http\Interfaces\HttpStatus; use PHPUnit\Framework\TestCase; class StatusCodeTest extends TestCase @@ -16,8 +17,8 @@ public function test__callStatic() public function test_description() { - $this->assertSame('', StatusCode::description(StatusCode::CREATED)); + $this->assertSame('', StatusCode::description(HttpStatus::CREATED)); $this->assertSame('The origin server requires the request to be conditional', - StatusCode::description(StatusCode::PRECONDITION_REQUIRED)); + StatusCode::description(HttpStatus::PRECONDITION_REQUIRED)); } } diff --git a/Uri.php b/Uri.php index 7d2d737..6a586de 100644 --- a/Uri.php +++ b/Uri.php @@ -13,6 +13,7 @@ namespace Koded\Http; use InvalidArgumentException; +use Koded\Http\Interfaces\HttpStatus; use Psr\Http\Message\UriInterface; use Throwable; @@ -199,7 +200,7 @@ public function withFragment($fragment): UriInterface private function parse(string $uri) { if (false === $parts = parse_url($uri)) { - throw new InvalidArgumentException('Please provide a valid URI', StatusCode::BAD_REQUEST); + throw new InvalidArgumentException('Please provide a valid URI', HttpStatus::BAD_REQUEST); } foreach ($parts as $k => $v) { diff --git a/VERSION b/VERSION index f93ea0c..50aea0e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.2 \ No newline at end of file +2.1.0 \ No newline at end of file diff --git a/diagrams/interfaces.png b/diagrams/interfaces.png index a3e9e9dc6d094eef8b093319cc7620ff6546ccfa..3624802717fdacd385c88c6d21c02ba3434640d8 100644 GIT binary patch literal 14152 zcmeHuWmH^Cw_pbn2*E8tAXspR4iZ5dg1fsr1PK;2xCVC(Zb3ui4uN1nf?Ef78h4pP za=&}O`{u3nX4W_I*39G2p-0SLs6DK0Fi-pqA(es0^T8n2B zv07jR--Q^jA1DmO1_6PP1^b5>w|{aD|g{F-zR zY(xPJeZKcUH6+Lh>5FG(xUw4F^au^PIi|oq7r2qYfzE(qrTZEVWX-$SbbYY)HHE<;El-Y zb{bwf`&>3fH0r&K`oMA)MfFr%KfKq?#&V$el`8AdD!U{bgxsc21UNO;6+0>HPm6QTz~~YNhN6=i zPGy*!f*USF7PVN}S+XP(YX-n3#YWBtssoc%7R@eoGK&|?KPGC04J#@ZbG0q0x5|x7 zM6S<1N{TODrZDJCv!+mJhy(`|4h;44X0)74G3-AyU0G$H9~9<(me-J{I?-gyk)yiW z%lzWlajE8Uv+cv>Ubh+tc;bKr?i=ey%hmLHyOj8l3{*)PC7YCI^H^yiNWC%} zK|jf3O~fw4!Yl&BxOVuOl(-ZRR{sv>?(+@Di zr+$*h2|=d8>+@p%&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rMc6>X$*FYK}3u0W^tAzr}66hKZ*7aI-UjoL!^F6<=)FIq5t@QY6;&(Fx-* ztYx{kIoI6WJUv4tI>M^mFZ+mZ4WSi5S5h!e2Yl)cAIJ{{>}6NQf+LBy&fpgD zDMvLOfuF2IMkzyX*t~4IMn)$Fxgqh~;JpEwY`#05si9tNraaWyY=3)6Pr}r6X|_Eg zfv}xH?jFD=!{fs}{UDzE#lcnbsGdj`B{4M#j$3Y0F^Dcrl?K`q!pnZ+EnF%r zK#aD@+w^W(i4?KkXF7{L;5tmFt8F`;6w^-Cbotr%shLo0eC&5d#lmlDgJts6ON<86C4{LM#8to0ZmMYltMEz8-oq(= zyb4qoK%nd#PNYd5PBZxvw=v??Hb5?BejU-&&>q1Q(ApWpNf81_jdQ@4kXBWz_Wcmt zBgI+6gC_h@wkI_^2-MlAiyB3aaUt`^+=m4w?ct2=7_fgWWAcp@nY-^@M8!L5-*1Nk zamA?SR^2oUS-IF-?nZhLXyXGklb%doQc|+(Dv!th_N;A~Y!~g-KfMmdFo2Onx|>Zm z`4f|~U1$AR%CPxi&o1?Bt*!OX{(W0Lg6kg>v!r0{b>0sYWtV$h#jG^zJZtu5?y($P z84xW$86BO}B=c`lh_92lQN!!iN&*52P2qq<&;yyc$io05#Sm@a$49g0le1E7W?H(F zgxw~qUC>N7XubjrX}jqu3*!Xr0x na|Z;X1{^KW)Boi0?#Ul?nE`ZPAFinYLqQTSS+RoWuipPJeEVzn From 3d7e1ecb0aaf78e58120abf37568fef491e7d5b1 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Tue, 14 Apr 2020 11:56:05 +0000 Subject: [PATCH 3/3] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- Interfaces.php | 6 ++-- StatusCode.php | 86 +++++++++++++++++++++++++------------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Interfaces.php b/Interfaces.php index 40f0ba6..5bc6fd6 100644 --- a/Interfaces.php +++ b/Interfaces.php @@ -305,7 +305,7 @@ public function validate(HttpInputValidator $validator): ?Response; interface HttpStatus { - const CODE = [ + const CODE = [ // Informational 1xx 100 => 'Continue', 101 => 'Switching Protocols', @@ -340,9 +340,9 @@ interface HttpStatus // Client Error 4xx 400 => 'Bad Request', - 401 => 'Unauthorized', // Really means "Unauthenticated" + 401 => 'Unauthorized', // Really means "Unauthenticated" 402 => 'Payment Required', - 403 => 'Forbidden', // Really means "Unauthorized" + 403 => 'Forbidden', // Really means "Unauthorized" 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', diff --git a/StatusCode.php b/StatusCode.php index 2d89b95..8d7fd43 100644 --- a/StatusCode.php +++ b/StatusCode.php @@ -30,54 +30,54 @@ class StatusCode implements HttpStatus public static function description(int $code): string { return [ - // 4xx + // 4xx - self::BAD_REQUEST => 'The response means that server cannot understand the request due to invalid syntax', - self::UNAUTHORIZED => 'The request has not been applied because it lacks valid authentication credentials for the target resource', - self::FORBIDDEN => 'Client does not have access rights to the content, so the server refuses to authorize it', - self::NOT_FOUND => 'Server cannot find the requested resource', - self::METHOD_NOT_ALLOWED => 'The request method is known by the server, but has been disabled and cannot be used', - self::NOT_ACCEPTABLE => 'The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation', - self::PROXY_AUTHENTICATION_REQUIRED => 'Similar to 401 Unauthorized, but it indicates that the client needs to authenticate itself in order to use a proxy (Proxy-Authenticate request header)', - self::REQUEST_TIMEOUT => 'The server did not receive a complete request message within the time that it was prepared to wait', - self::CONFLICT => 'The request could not be completed due to a conflict with the current state of the target resource', - self::GONE => 'The target resource is no longer available at the origin server and that this condition is likely to be permanent', - self::LENGTH_REQUIRED => 'The server refuses to accept the request without a defined Content-Length', - self::PRECONDITION_FAILED => 'The client sent preconditions in the request headers that failed to evaluate on the server', - self::PAYLOAD_TOO_LARGE => 'The server is refusing to process a request because the request payload is larger than the server is willing or able to process', - self::REQUEST_URI_TOO_LONG => 'The server is refusing to service the request because the request-target is longer than the server is willing to interpret', - self::UNSUPPORTED_MEDIA_TYPE => 'The media format of the requested data is not supported by the server', - self::EXPECTATION_FAILED => 'The expectation given in the Expect request header could not be met by at least one of the inbound servers', - self::I_AM_TEAPOT => 'Any attempt to brew coffee with a teapot should result in the error code "418 I\'m a teapot". The resulting entity body MAY be short and stout', - self::MISDIRECTED_REQUEST => 'The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI', - self::UNPROCESSABLE_ENTITY => 'The server understands the content type of the request entity, and the syntax of the request entity is correct, but was unable to process the contained instructions (i.e. has semantic errors)', - self::LOCKED => 'The source or destination resource of a method is locked', - self::FAILED_DEPENDENCY => 'The method could not be performed on the resource because the requested action depended on another action and that action failed', - self::UPGRADE_REQUIRED => 'The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol', - self::PRECONDITION_REQUIRED => 'The origin server requires the request to be conditional', - self::TOO_MANY_REQUESTS => 'The user has sent too many requests in a given amount of time ("rate limiting")', - self::REQUEST_HEADER_FIELDS_TOO_LARGE => 'The server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields', - self::UNAVAILABLE_FOR_LEGAL_REASONS => 'The server is denying access to the resource as a consequence of a legal demand', + self::BAD_REQUEST => 'The response means that server cannot understand the request due to invalid syntax', + self::UNAUTHORIZED => 'The request has not been applied because it lacks valid authentication credentials for the target resource', + self::FORBIDDEN => 'Client does not have access rights to the content, so the server refuses to authorize it', + self::NOT_FOUND => 'Server cannot find the requested resource', + self::METHOD_NOT_ALLOWED => 'The request method is known by the server, but has been disabled and cannot be used', + self::NOT_ACCEPTABLE => 'The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation', + self::PROXY_AUTHENTICATION_REQUIRED => 'Similar to 401 Unauthorized, but it indicates that the client needs to authenticate itself in order to use a proxy (Proxy-Authenticate request header)', + self::REQUEST_TIMEOUT => 'The server did not receive a complete request message within the time that it was prepared to wait', + self::CONFLICT => 'The request could not be completed due to a conflict with the current state of the target resource', + self::GONE => 'The target resource is no longer available at the origin server and that this condition is likely to be permanent', + self::LENGTH_REQUIRED => 'The server refuses to accept the request without a defined Content-Length', + self::PRECONDITION_FAILED => 'The client sent preconditions in the request headers that failed to evaluate on the server', + self::PAYLOAD_TOO_LARGE => 'The server is refusing to process a request because the request payload is larger than the server is willing or able to process', + self::REQUEST_URI_TOO_LONG => 'The server is refusing to service the request because the request-target is longer than the server is willing to interpret', + self::UNSUPPORTED_MEDIA_TYPE => 'The media format of the requested data is not supported by the server', + self::EXPECTATION_FAILED => 'The expectation given in the Expect request header could not be met by at least one of the inbound servers', + self::I_AM_TEAPOT => 'Any attempt to brew coffee with a teapot should result in the error code "418 I\'m a teapot". The resulting entity body MAY be short and stout', + self::MISDIRECTED_REQUEST => 'The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI', + self::UNPROCESSABLE_ENTITY => 'The server understands the content type of the request entity, and the syntax of the request entity is correct, but was unable to process the contained instructions (i.e. has semantic errors)', + self::LOCKED => 'The source or destination resource of a method is locked', + self::FAILED_DEPENDENCY => 'The method could not be performed on the resource because the requested action depended on another action and that action failed', + self::UPGRADE_REQUIRED => 'The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol', + self::PRECONDITION_REQUIRED => 'The origin server requires the request to be conditional', + self::TOO_MANY_REQUESTS => 'The user has sent too many requests in a given amount of time ("rate limiting")', + self::REQUEST_HEADER_FIELDS_TOO_LARGE => 'The server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields', + self::UNAVAILABLE_FOR_LEGAL_REASONS => 'The server is denying access to the resource as a consequence of a legal demand', - // 5xx + // 5xx - self::INTERNAL_SERVER_ERROR => 'The server encountered an unexpected condition that prevented it from fulfilling the request', - self::NOT_IMPLEMENTED => 'The server does not support the functionality required to fulfill the request', - self::BAD_GATEWAY => 'The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request', - self::SERVICE_UNAVAILABLE => 'The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay', - self::GATEWAY_TIMEOUT => 'The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request', - self::VERSION_NOT_SUPPORTED => 'The server does not support, or refuses to support, the major version of HTTP that was used in the request message', - self::VARIANT_ALSO_NEGOTIATES => 'The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process', - self::INSUFFICIENT_STORAGE => 'The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request', - self::LOOP_DETECTED => 'The server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". This status indicates that the entire operation failed', - self::BANDWIDTH_LIMIT_EXCEEDED => 'Not part of the HTTP standard. It is issued when the servers bandwidth limits have been exceeded', - self::NOT_EXTENDED => 'The policy for accessing the resource has not been met in the request. The server should send back all the information necessary for the client to issue an extended request', + self::INTERNAL_SERVER_ERROR => 'The server encountered an unexpected condition that prevented it from fulfilling the request', + self::NOT_IMPLEMENTED => 'The server does not support the functionality required to fulfill the request', + self::BAD_GATEWAY => 'The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request', + self::SERVICE_UNAVAILABLE => 'The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay', + self::GATEWAY_TIMEOUT => 'The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request', + self::VERSION_NOT_SUPPORTED => 'The server does not support, or refuses to support, the major version of HTTP that was used in the request message', + self::VARIANT_ALSO_NEGOTIATES => 'The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process', + self::INSUFFICIENT_STORAGE => 'The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request', + self::LOOP_DETECTED => 'The server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". This status indicates that the entire operation failed', + self::BANDWIDTH_LIMIT_EXCEEDED => 'Not part of the HTTP standard. It is issued when the servers bandwidth limits have been exceeded', + self::NOT_EXTENDED => 'The policy for accessing the resource has not been met in the request. The server should send back all the information necessary for the client to issue an extended request', - self::HTTP_NETWORK_AUTHENTICATION_REQUIRED => 'The client needs to authenticate to gain network access', + self::HTTP_NETWORK_AUTHENTICATION_REQUIRED => 'The client needs to authenticate to gain network access', - self::SERVICE_NOT_FOUND => 'The requested service is not found on the server. The service is determined by the part of the endpoint, which may indicate that the provided service name is invalid', + self::SERVICE_NOT_FOUND => 'The requested service is not found on the server. The service is determined by the part of the endpoint, which may indicate that the provided service name is invalid', - ][$code] ?? ''; + ][$code] ?? ''; } /** @@ -90,7 +90,7 @@ public static function __callStatic(string $code, $withCode): ?string { try { $withCode += [false]; - $status = constant("self::$code"); + $status = constant("self::$code"); return ($withCode[0] ? $status . ' ' : '') . self::CODE[$status]; } catch (Exception $e) {