mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Look for parsed headers in the cache before trying to parse
This commit is contained in:
parent
f212cafad2
commit
adc363919c
1 changed files with 8 additions and 1 deletions
|
@ -307,8 +307,15 @@ parse_header(Name, Req, Default) ->
|
|||
{Value, Req2} = header(Name, Req, Default),
|
||||
{undefined, Value, Req2}.
|
||||
|
||||
%% @todo This doesn't look in the cache.
|
||||
parse_header(Name, Req=#http_req{p_headers=PHeaders}, Default, Fun) ->
|
||||
case lists:keyfind(Name, 1, PHeaders) of
|
||||
{Name, P} ->
|
||||
{P, Req};
|
||||
false ->
|
||||
parse_header_no_cache(Name, Req, Default, Fun)
|
||||
end.
|
||||
|
||||
parse_header_no_cache(Name, Req=#http_req{p_headers=PHeaders}, Default, Fun) ->
|
||||
case header(Name, Req) of
|
||||
{undefined, Req2} ->
|
||||
{Default, Req2#http_req{p_headers=[{Name, Default}|PHeaders]}};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue