HTTP-Promise
view release on metacpan or search on metacpan
lib/HTTP/Promise/Status.pm view on Meta::CPAN
This is used to indicate that the TCP conncection is switching to a different protocol.
This is typically used for the L<WebSocket> protocol, which uses initially a HTTP handshake when establishing the connection. For example:
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
Then the server could reply something like:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: chat
=head2 HTTP_PROCESSING (102)
See L<rfc 2518 on WebDAV|https://tools.ietf.org/html/rfc2518>
This is returned to notify the client that the server is currently processing the request and that it is taking some time.
The server could return repeated instance of this response code until it is done processing the request and then send back the actual final response headers.
=head2 HTTP_EARLY_HINTS (103)
See L<rfc 8297 on Indicating Hints|https://tools.ietf.org/html/rfc8297>
This is a preemptive return code to notify the client to make some optimisations, while the actual final response headers are sent later. For example:
HTTP/1.1 103 Early Hints
Link: </style.css>; rel=preload; as=style
Link: </script.js>; rel=preload; as=script
then, a few seconds, or minutes later:
HTTP/1.1 200 OK
Date: Mon, 16 Apr 2022 02:15:12 GMT
Content-Length: 1234
Content-Type: text/html; charset=utf-8
Link: </style.css>; rel=preload; as=style
Link: </script.js>; rel=preload; as=script
=head2 HTTP_OK (200)
See L<rfc7231, section 6.3.1|https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1>
This is returned to inform the request has succeeded. It can also alternatively be C<204 No Content> when there is no response body.
For example:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 184
Connection: keep-alive
Cache-Control: s-maxage=300, public, max-age=0
Content-Language: en-US
Date: Mon, 18 Apr 2022 17:37:18 GMT
ETag: "2e77ad1dc6ab0b53a2996dfd4653c1c3"
Server: Apache/2.4
Strict-Transport-Security: max-age=63072000
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Vary: Accept-Encoding,Cookie
Age: 7
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A simple webpage</title>
</head>
<body>
<h1>Simple HTML5 webpage</h1>
<p>Hello, world!</p>
</body>
</html>
=head2 HTTP_CREATED (201)
See L<rfc7231, section 6.3.2|https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2>
This is returned to notify the related resource has been created, most likely by a C<PUT> request, such as:
PUT /some/where HTTP/1.1
Content-Type: text/html
Host: example.org
Then, the server would reply:
HTTP/1.1 201 Created
ETag: "foo-bar"
=head2 HTTP_ACCEPTED (202)
See L<rfc7231, section 6.3.3|https://tools.ietf.org/html/rfc7231#section-6.3.3>
This is returned when the web server has accepted the request, without guarantee of successful completion.
Thus, the remote service would typically send an email to inform the user of the status, or maybe provide a link in the header. For example:
POST /some/where HTTP/1.1
Content-Type: application/json
Then the server response:
HTTP/1.1 202 Accepted
Link: </some/status/1234> rel="https://example.org/status"
Content-Length: 0
=head2 HTTP_NON_AUTHORITATIVE (203)
See L<rfc 7231, section 6.3.4|https://tools.ietf.org/html/rfc7231#section-6.3.4>
( run in 0.392 second using v1.01-cache-2.11-cpan-5511b514fd6 )