Apache2-API
view release on metacpan or search on metacpan
lib/Apache2/API/Status.pm view on Meta::CPAN
Server: Apache/2.4
Content-Type: text/html; charset=UTF-8
Location: https://example.org/some/where/else.html
Content-Length: 393
<!DOCTYPE HTML>
<html>
<head>
<title>Permanent Redirect</title>
<meta http-equiv="refresh"
content="0; url=https://example.org/some/where/else.html">
</head>
<body>
<p>
The document has been moved to
<a href="https://example.org/some/where/else.html"
>https://example.org/some/where/else.html</a>.
</p>
</body>
</html>
=head2 HTTP_BAD_REQUEST (400)
See L<rfc 7231, section 6.5.1|https://tools.ietf.org/html/rfc7231#section-6.5.1>
This is returned to indicate the client made a request the server could not interpret.
This is generally used as a fallback client-error code when other mode detailed C<4xx> code are not suitable.
=head2 HTTP_UNAUTHORIZED (401)
See L<rfc 7235, section 3.1 on Authentication|https://tools.ietf.org/html/rfc7235#section-3.1>
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401>
This is returned to indicate to the client it must authenticate first before issuing the request.
See also status code C<403 Forbidden> when client is outright forbidden from accessing the resource.
For example:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic; realm="Secured area"
or, for APIs:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer
or, combining both:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic; realm="Dev zone", Bearer
which equates to:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic; realm="Dev zone"
WWW-Authenticate: Bearer
So, for example, a user C<aladdin> with password C<opensesame> would result in the following request:
GET / HTTP/1.1
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
See also L<Mozilla documentation on Authorization header|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization>
=head2 HTTP_PAYMENT_REQUIRED (402)
See L<rfc 7231, section 6.5.2|https://tools.ietf.org/html/rfc7231#section-6.5.2>
This was originally designed to inform the client that the resource could only be accessed once payment was made, but is now reserved and its current use is left at the discretion of the site implementing it.
=head2 HTTP_FORBIDDEN (403)
See L<rfc 7231, section 6.5.3|https://tools.ietf.org/html/rfc7231#section-6.5.3>
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403>
This is returned to indicate the client is barred from accessing the resource.
This is different from C<405 Method Not Allowed>, which is used when the client has proper permission to access the resource, but is using a method not allowed, such as using C<PUT> instead of C<GET> method.
=head2 HTTP_NOT_FOUND (404)
See L<rfc 7231, section 6.5.4|https://tools.ietf.org/html/rfc7231#section-6.5.4>
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404>
This is returned to indicate the resource does not exist anymore.
=head2 HTTP_METHOD_NOT_ALLOWED (405)
See L<rfc 7231, section 6.5.5|https://tools.ietf.org/html/rfc7231#section-6.5.5>
This is returned to indicate the client it used a L<method|https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods> not allowed, such as using C<PUT> instead of C<GET>. The server can point out the supported methods with the C<Allow> header, such a...
HTTP/1.1 405 Method Not Allowed
Content-Type: text/html
Content-Length: 32
Allow: GET, HEAD, OPTIONS, PUT
<h1>405 Try another method!</h1>
=head2 HTTP_NOT_ACCEPTABLE (406)
See L<rfc 7231, section 6.5.6|https://tools.ietf.org/html/rfc7231#section-6.5.6>
This is returned to the client to indicate its requirements are not supported and thus not acceptable. This is in response to L<Accept|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept>, L<Accept-Charset|https://developer.mozilla.org/e...
For example:
GET /foo HTTP/1.1
Accept: application/json
Accept-Language: fr-FR,en-GB;q=0.8,fr;q=0.6,en;q=0.4,ja;q=0.2
HTTP/1.1 406 Not Acceptable
Server: Apache/2.4
Content-Type: text/html
<h1>Je ne gère pas le type application/json</h1>
( run in 0.545 second using v1.01-cache-2.11-cpan-39bf76dae61 )