aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-07-22 05:15:15 +0200
committerLoïc Hoguin <[email protected]>2012-07-22 05:15:15 +0200
commitadc363919c7b21ceb43625af37c933b002e1c7e8 (patch)
treeeaacd3888c529e8c707cbc6750118a4bbe6f66b6 /src
parentf212cafad20c498c927c85a39881a5b771727826 (diff)
downloadcowboy-adc363919c7b21ceb43625af37c933b002e1c7e8.tar.gz
cowboy-adc363919c7b21ceb43625af37c933b002e1c7e8.tar.bz2
cowboy-adc363919c7b21ceb43625af37c933b002e1c7e8.zip
Look for parsed headers in the cache before trying to parse
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_http_req.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index 70d627d..6f5fdfa 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -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]}};