From f3d6b05b863fe177a34a8a6ba48c5f263ef8cf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 29 Oct 2017 19:52:27 +0000 Subject: Add cowboy_req:inform/2,3 User code can now send as many 1xx responses as necessary. --- src/cowboy_http2.erl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/cowboy_http2.erl') 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. -- cgit v1.2.3