diff options
author | Loïc Hoguin <[email protected]> | 2014-12-13 14:42:43 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-12-13 14:46:05 +0200 |
commit | 86917a4c641f01c18f53b34bc4bc89c20549f04a (patch) | |
tree | 45e8fc0b1b4b49d6a135c81d404857648976cc85 /include/cow_inline.hrl | |
parent | 847b1bca21cc2ddec6b94f2a8f8924ad3f4be73a (diff) | |
download | cowlib-86917a4c641f01c18f53b34bc4bc89c20549f04a.tar.gz cowlib-86917a4c641f01c18f53b34bc4bc89c20549f04a.tar.bz2 cowlib-86917a4c641f01c18f53b34bc4bc89c20549f04a.zip |
Add cow_http_hd:parse_accept_language/1
From RFC7231.
This code is more than twice faster as the current Cowboy code,
while filtering out more bad cases.
Diffstat (limited to 'include/cow_inline.hrl')
-rw-r--r-- | include/cow_inline.hrl | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/include/cow_inline.hrl b/include/cow_inline.hrl index 82cc465..a72f8c5 100644 --- a/include/cow_inline.hrl +++ b/include/cow_inline.hrl @@ -15,15 +15,9 @@ -ifndef(COW_INLINE_HRL). -define(COW_INLINE_HRL, 1). -%% IS_DIGIT(Character) +%% IS_ALPHA(Character) --define(IS_DIGIT(C), - C >= $0, C =< $9 -). - -%% IS_TOKEN(Character) - --define(IS_TOKEN(C), +-define(IS_ALPHA(C), C =:= $a; C =:= $b; C =:= $c; C =:= $d; C =:= $e; C =:= $f; C =:= $g; C =:= $h; C =:= $i; C =:= $j; C =:= $k; C =:= $l; C =:= $m; C =:= $n; C =:= $o; @@ -35,9 +29,20 @@ C =:= $K; C =:= $L; C =:= $M; C =:= $N; C =:= $O; C =:= $P; C =:= $Q; C =:= $R; C =:= $S; C =:= $T; C =:= $U; C =:= $V; C =:= $W; C =:= $X; C =:= $Y; - C =:= $2; + C =:= $2 +). + +%% IS_DIGIT(Character) + +-define(IS_DIGIT(C), C =:= $0; C =:= $1; C =:= $2; C =:= $3; C =:= $4; - C =:= $5; C =:= $6; C =:= $7; C =:= $8; C =:= $9; + C =:= $5; C =:= $6; C =:= $7; C =:= $8; C =:= $9 +). + +%% IS_TOKEN(Character) + +-define(IS_TOKEN(C), + ?IS_ALPHA(C); ?IS_DIGIT(C); C =:= $!; C =:= $#; C =:= $$; C =:= $%; C =:= $&; C =:= $'; C =:= $*; C =:= $+; C =:= $-; C =:= $.; C =:= $^; C =:= $_; C =:= $`; C =:= $|; C =:= $~ |