diff options
author | Loïc Hoguin <[email protected]> | 2012-09-16 23:54:29 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2012-09-17 13:57:28 +0200 |
commit | 905083a7fddcc7680405c504a646da9a70e3059e (patch) | |
tree | 22a3ae785903e5a2f5bb0caf0f51b669e21896c1 /src/cowboy_req.erl | |
parent | 350d4ae3f2e9973b3638b06c7092370afa08e634 (diff) | |
download | cowboy-905083a7fddcc7680405c504a646da9a70e3059e.tar.gz cowboy-905083a7fddcc7680405c504a646da9a70e3059e.tar.bz2 cowboy-905083a7fddcc7680405c504a646da9a70e3059e.zip |
Add the private set_connection/2 function used by cowboy_protocol
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. |