mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Add the private add_header/3 function used by cowboy_protocol
This commit is contained in:
parent
905083a7fd
commit
fc02b7f767
2 changed files with 8 additions and 2 deletions
|
@ -205,8 +205,7 @@ header({http_header, _I, 'Connection', _R, Connection}, Req,
|
||||||
parse_header(cowboy_req:set_connection(Connection, Req), State);
|
parse_header(cowboy_req:set_connection(Connection, Req), 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(cowboy_req:add_header(Field2, Value, Req), State);
|
||||||
State);
|
|
||||||
%% The Host header is required in HTTP/1.1 and optional in HTTP/1.0.
|
%% The Host header is required in HTTP/1.1 and optional in HTTP/1.0.
|
||||||
header(http_eoh, Req, State=#state{host_tokens=undefined,
|
header(http_eoh, Req, State=#state{host_tokens=undefined,
|
||||||
buffer=Buffer, transport=Transport}) ->
|
buffer=Buffer, transport=Transport}) ->
|
||||||
|
|
|
@ -105,6 +105,7 @@
|
||||||
%% Private setter/getter API.
|
%% Private setter/getter API.
|
||||||
-export([set_host/4]).
|
-export([set_host/4]).
|
||||||
-export([set_connection/2]).
|
-export([set_connection/2]).
|
||||||
|
-export([add_header/3]).
|
||||||
|
|
||||||
%% Misc API.
|
%% Misc API.
|
||||||
-export([compact/1]).
|
-export([compact/1]).
|
||||||
|
@ -928,6 +929,12 @@ set_connection(RawConnection, Req=#http_req{headers=Headers}) ->
|
||||||
ConnAtom = cowboy_http:connection_to_atom(ConnTokens),
|
ConnAtom = cowboy_http:connection_to_atom(ConnTokens),
|
||||||
Req3#http_req{connection=ConnAtom}.
|
Req3#http_req{connection=ConnAtom}.
|
||||||
|
|
||||||
|
%% @private
|
||||||
|
-spec add_header(cowboy_http:header(), binary(), Req)
|
||||||
|
-> Req when Req::req().
|
||||||
|
add_header(Name, Value, Req=#http_req{headers=Headers}) ->
|
||||||
|
Req#http_req{headers=[{Name, Value}|Headers]}.
|
||||||
|
|
||||||
%% 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