0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-16 05:00:24 +00:00

Make the HTTP version type more practical

Now instead of {1, 1} we have 'HTTP/1.1', and instead of {1, 0}
we have 'HTTP/1.0'. This is more efficient, easier to read in
crash logs, and clearer in the code.
This commit is contained in:
Loïc Hoguin 2013-05-16 12:56:01 +02:00
parent e0b5526f1e
commit 28186a68d0
5 changed files with 25 additions and 29 deletions

View file

@ -46,14 +46,13 @@
%% Interpretation.
-export([cookie_to_iodata/3]).
-export([version_to_binary/1]).
-export([urldecode/1]).
-export([urldecode/2]).
-export([urlencode/1]).
-export([urlencode/2]).
-export([x_www_form_urlencoded/1]).
-type version() :: {Major::non_neg_integer(), Minor::non_neg_integer()}.
-type version() :: 'HTTP/1.1' | 'HTTP/1.0'.
-type headers() :: [{binary(), iodata()}].
-type status() :: non_neg_integer() | binary().
@ -1001,11 +1000,6 @@ cookie_to_iodata(Name, Value, Opts) ->
[Name, <<"=">>, Value, <<"; Version=1">>,
MaxAgeBin, DomainBin, PathBin, SecureBin, HttpOnlyBin].
%% @doc Convert an HTTP version tuple to its binary form.
-spec version_to_binary(version()) -> binary().
version_to_binary({1, 1}) -> <<"HTTP/1.1">>;
version_to_binary({1, 0}) -> <<"HTTP/1.0">>.
%% @doc Decode a URL encoded binary.
%% @equiv urldecode(Bin, crash)
-spec urldecode(binary()) -> binary().