diff options
author | Loïc Hoguin <[email protected]> | 2017-10-29 19:52:27 +0000 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-10-29 21:03:04 +0000 |
commit | f3d6b05b863fe177a34a8a6ba48c5f263ef8cf82 (patch) | |
tree | fc3235ad43880f29186bce373a3c79057c83e060 /src/cowboy_http2.erl | |
parent | f4331f7c169309c9017b9628fe3757fc5312270b (diff) | |
download | cowboy-f3d6b05b863fe177a34a8a6ba48c5f263ef8cf82.tar.gz cowboy-f3d6b05b863fe177a34a8a6ba48c5f263ef8cf82.tar.bz2 cowboy-f3d6b05b863fe177a34a8a6ba48c5f263ef8cf82.zip |
Add cowboy_req:inform/2,3
User code can now send as many 1xx responses as necessary.
Diffstat (limited to 'src/cowboy_http2.erl')
-rw-r--r-- | src/cowboy_http2.erl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl index d863d1a..663d33a 100644 --- a/src/cowboy_http2.erl +++ b/src/cowboy_http2.erl @@ -495,6 +495,13 @@ commands(State, Stream=#stream{local=idle}, [{error_response, StatusCode, Header commands(State, Stream, [{response, StatusCode, Headers, Body}|Tail]); commands(State, Stream, [{error_response, _, _, _}|Tail]) -> commands(State, Stream, Tail); +%% Send an informational response. +commands(State=#state{socket=Socket, transport=Transport, encode_state=EncodeState0}, + Stream=#stream{id=StreamID, local=idle}, [{inform, StatusCode, Headers0}|Tail]) -> + Headers = Headers0#{<<":status">> => status(StatusCode)}, + {HeaderBlock, EncodeState} = headers_encode(Headers, EncodeState0), + Transport:send(Socket, cow_http2:headers(StreamID, fin, HeaderBlock)), + commands(State#state{encode_state=EncodeState}, Stream, Tail); %% Send response headers. %% %% @todo Kill the stream if it sent a response when one has already been sent. |