mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Add the private set_connection/2 function used by cowboy_protocol
This commit is contained in:
parent
350d4ae3f2
commit
905083a7fd
2 changed files with 12 additions and 8 deletions
|
@ -199,15 +199,10 @@ header({http_header, _I, 'Host', _R, RawHost}, Req,
|
||||||
%% Ignore Host headers if we already have it.
|
%% Ignore Host headers if we already have it.
|
||||||
header({http_header, _I, 'Host', _R, _V}, Req, State) ->
|
header({http_header, _I, 'Host', _R, _V}, Req, State) ->
|
||||||
parse_header(Req, State);
|
parse_header(Req, State);
|
||||||
header({http_header, _I, 'Connection', _R, Connection},
|
header({http_header, _I, 'Connection', _R, Connection}, Req,
|
||||||
Req=#http_req{headers=Headers}, State=#state{
|
State=#state{req_keepalive=Keepalive, max_keepalive=MaxKeepalive})
|
||||||
req_keepalive=Keepalive, max_keepalive=MaxKeepalive})
|
|
||||||
when Keepalive < MaxKeepalive ->
|
when Keepalive < MaxKeepalive ->
|
||||||
Req2 = Req#http_req{headers=[{'Connection', Connection}|Headers]},
|
parse_header(cowboy_req:set_connection(Connection, Req), State);
|
||||||
{ok, ConnTokens, Req3}
|
|
||||||
= cowboy_req:parse_header('Connection', Req2),
|
|
||||||
ConnAtom = cowboy_http:connection_to_atom(ConnTokens),
|
|
||||||
parse_header(Req3#http_req{connection=ConnAtom}, State);
|
|
||||||
header({http_header, _I, Field, _R, Value}, Req, State) ->
|
header({http_header, _I, Field, _R, Value}, Req, State) ->
|
||||||
Field2 = format_header(Field),
|
Field2 = format_header(Field),
|
||||||
parse_header(Req#http_req{headers=[{Field2, Value}|Req#http_req.headers]},
|
parse_header(Req#http_req{headers=[{Field2, Value}|Req#http_req.headers]},
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
|
|
||||||
%% Private setter/getter API.
|
%% Private setter/getter API.
|
||||||
-export([set_host/4]).
|
-export([set_host/4]).
|
||||||
|
-export([set_connection/2]).
|
||||||
|
|
||||||
%% Misc API.
|
%% Misc API.
|
||||||
-export([compact/1]).
|
-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}) ->
|
set_host(Host, Port, RawHost, Req=#http_req{headers=Headers}) ->
|
||||||
Req#http_req{host=Host, port=Port, headers=[{'Host', RawHost}|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.
|
%% Misc API.
|
||||||
|
|
||||||
%% @doc Compact the request data by removing all non-system information.
|
%% @doc Compact the request data by removing all non-system information.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue