aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_bstr.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-03-26 19:05:59 +0100
committerLoïc Hoguin <[email protected]>2014-03-26 19:05:59 +0100
commit17af50812c47f5dec7e02e443c551b9697715729 (patch)
tree40684eb74e67302078f4552fab0bbd1a9dbe2d01 /src/cowboy_bstr.erl
parent9110ee83fe47e4c41b6c001b9ae401979f8ebe4c (diff)
downloadcowboy-17af50812c47f5dec7e02e443c551b9697715729.tar.gz
cowboy-17af50812c47f5dec7e02e443c551b9697715729.tar.bz2
cowboy-17af50812c47f5dec7e02e443c551b9697715729.zip
Remove outdated comments, all edoc, plus a few minor tweaks
Diffstat (limited to 'src/cowboy_bstr.erl')
-rw-r--r--src/cowboy_bstr.erl14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/cowboy_bstr.erl b/src/cowboy_bstr.erl
index 92e3f29..98d2cf7 100644
--- a/src/cowboy_bstr.erl
+++ b/src/cowboy_bstr.erl
@@ -12,7 +12,6 @@
%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-%% @doc Binary string manipulation.
-module(cowboy_bstr).
%% Binary strings.
@@ -24,11 +23,9 @@
-export([char_to_lower/1]).
-export([char_to_upper/1]).
-%% @doc Capitalize a token.
-%%
%% The first letter and all letters after a dash are capitalized.
%% This is the form seen for header names in the HTTP/1.1 RFC and
-%% others. Note that using this form isn't required, as header name
+%% others. Note that using this form isn't required, as header names
%% are case insensitive, and it is only provided for use with eventual
%% badly implemented clients.
-spec capitalize_token(B) -> B when B::binary().
@@ -43,19 +40,14 @@ capitalize_token(<< C, Rest/bits >>, true, Acc) ->
capitalize_token(<< C, Rest/bits >>, false, Acc) ->
capitalize_token(Rest, false, << Acc/binary, (char_to_lower(C)) >>).
-%% @doc Convert a binary string to lowercase.
-spec to_lower(B) -> B when B::binary().
to_lower(B) ->
<< << (char_to_lower(C)) >> || << C >> <= B >>.
-%% @doc Convert a binary string to uppercase.
-spec to_upper(B) -> B when B::binary().
to_upper(B) ->
<< << (char_to_upper(C)) >> || << C >> <= B >>.
-%% @doc Convert [A-Z] characters to lowercase.
-%% @end
-%% We gain noticeable speed by matching each value directly.
-spec char_to_lower(char()) -> char().
char_to_lower($A) -> $a;
char_to_lower($B) -> $b;
@@ -85,7 +77,6 @@ char_to_lower($Y) -> $y;
char_to_lower($Z) -> $z;
char_to_lower(Ch) -> Ch.
-%% @doc Convert [a-z] characters to uppercase.
-spec char_to_upper(char()) -> char().
char_to_upper($a) -> $A;
char_to_upper($b) -> $B;
@@ -118,9 +109,7 @@ char_to_upper(Ch) -> Ch.
%% Tests.
-ifdef(TEST).
-
capitalize_token_test_() ->
- %% {Header, Result}
Tests = [
{<<"heLLo-woRld">>, <<"Hello-World">>},
{<<"Sec-Websocket-Version">>, <<"Sec-Websocket-Version">>},
@@ -131,5 +120,4 @@ capitalize_token_test_() ->
{<<"Sec-WebSocket---Version">>, <<"Sec-Websocket---Version">>}
],
[{H, fun() -> R = capitalize_token(H) end} || {H, R} <- Tests].
-
-endif.