0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00

Add cowboy_req:inform/2,3

User code can now send as many 1xx responses as necessary.
This commit is contained in:
Loïc Hoguin 2017-10-29 19:52:27 +00:00
parent f4331f7c16
commit f3d6b05b86
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
11 changed files with 206 additions and 1 deletions

View file

@ -262,6 +262,29 @@ Req = cowboy_req:reply(200, #{
// example would be automatic concatenation of CSS or JS
// files.
=== Informational responses
Cowboy allows you to send informational responses.
Informational responses are responses that have a status
code between 100 and 199. Any number can be sent before
the proper response. Sending an informational response
does not change the behavior of the proper response, and
clients are expected to ignore any informational response
they do not understand.
The following snippet sends a 103 informational response
with some headers that are expected to be in the final
response.
[source,erlang]
----
Req = cowboy_req:inform(103, #{
<<"link">> => <<"</style.css>; rel=preload; as=style">>,
<<"link">> => <<"</script.js>; rel=preload; as=script">>
}, Req0).
----
=== Push
The HTTP/2 protocol introduced the ability to push resources