From 1e7338bdd4768123da177895ec6c91d3dabb7ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 17 Oct 2011 09:15:01 +0200 Subject: Rewrite the token list parsing into separate, modulable functions Introduce cowboy_http's list/2, nonempty_list/2, token/2 functions. --- src/cowboy_http_req.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cowboy_http_req.erl') diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl index a7b0533..da7c16f 100644 --- a/src/cowboy_http_req.erl +++ b/src/cowboy_http_req.erl @@ -220,7 +220,7 @@ parse_header(Name, Req=#http_req{p_headers=PHeaders}, Default) case header(Name, Req) of {undefined, Req2} -> {tokens, Default, Req2}; {Value, Req2} -> - case cowboy_http:parse_tokens_list(Value) of + case cowboy_http:nonempty_list(Value, fun cowboy_http:token/2) of {error, badarg} -> {error, badarg}; P -> @@ -417,7 +417,7 @@ response_connection([{Name, Value}|Tail], Connection) -> -spec response_connection_parse(binary()) -> keepalive | close. response_connection_parse(ReplyConn) -> - Tokens = cowboy_http:parse_tokens_list(ReplyConn), + Tokens = cowboy_http:nonempty_list(ReplyConn, fun cowboy_http:token/2), cowboy_http:connection_to_atom(Tokens). -spec response_head(http_status(), http_headers(), http_headers()) -> iolist(). -- cgit v1.2.3