From cd7f37d34645dd2f54175d60632f9684cf064c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 27 Sep 2012 01:31:19 +0200 Subject: Optimize Connection header parsing Still optimizing the critical path. Removes cowboy_http:connection_to_atom/1. --- src/cowboy_http.erl | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'src/cowboy_http.erl') diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index c3bef2f..6ba4834 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -42,7 +42,6 @@ -export([ce_identity/1]). %% Interpretation. --export([connection_to_atom/1]). -export([version_to_binary/1]). -export([urldecode/1]). -export([urldecode/2]). @@ -773,20 +772,6 @@ ce_identity(Data) -> %% Interpretation. -%% @doc Walk through a tokens list and return whether -%% the connection is keepalive or closed. -%% -%% The connection token is expected to be lower-case. --spec connection_to_atom([binary()]) -> keepalive | close. -connection_to_atom([]) -> - keepalive; -connection_to_atom([<<"keep-alive">>|_Tail]) -> - keepalive; -connection_to_atom([<<"close">>|_Tail]) -> - close; -connection_to_atom([_Any|Tail]) -> - connection_to_atom(Tail). - %% @doc Convert an HTTP version tuple to its binary form. -spec version_to_binary(version()) -> binary(). version_to_binary({1, 1}) -> <<"HTTP/1.1">>; @@ -1030,16 +1015,6 @@ asctime_date_test_() -> ], [{V, fun() -> R = asctime_date(V) end} || {V, R} <- Tests]. -connection_to_atom_test_() -> - %% {Tokens, Result} - Tests = [ - {[<<"close">>], close}, - {[<<"keep-alive">>], keepalive}, - {[<<"keep-alive">>, <<"upgrade">>], keepalive} - ], - [{lists:flatten(io_lib:format("~p", [T])), - fun() -> R = connection_to_atom(T) end} || {T, R} <- Tests]. - content_type_test_() -> %% {ContentType, Result} Tests = [ -- cgit v1.2.3