diff options
Diffstat (limited to 'src/cowboy_req.erl')
-rw-r--r-- | src/cowboy_req.erl | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl index 08e4155..8653efe 100644 --- a/src/cowboy_req.erl +++ b/src/cowboy_req.erl @@ -104,6 +104,7 @@ %% Private setter/getter API. -export([set_host/4]). +-export([set_connection/2]). %% Misc API. -export([compact/1]). @@ -919,6 +920,14 @@ ensure_response(#http_req{socket=Socket, transport=Transport, set_host(Host, Port, RawHost, Req=#http_req{headers=Headers}) -> Req#http_req{host=Host, port=Port, headers=[{'Host', RawHost}|Headers]}. +%% @private +-spec set_connection(binary(), Req) -> Req when Req::req(). +set_connection(RawConnection, Req=#http_req{headers=Headers}) -> + Req2 = Req#http_req{headers=[{'Connection', RawConnection}|Headers]}, + {ok, ConnTokens, Req3} = parse_header('Connection', Req2), + ConnAtom = cowboy_http:connection_to_atom(ConnTokens), + Req3#http_req{connection=ConnAtom}. + %% Misc API. %% @doc Compact the request data by removing all non-system information. |