aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-12-13 11:13:05 +0200
committerLoïc Hoguin <[email protected]>2014-12-13 13:10:22 +0200
commit20ada930c3996945fe2771518da05b5e7ae9b904 (patch)
tree8433054c9cdee4aa1ced11f992ee9dcf247f2cf6 /include
parent63f2e99b39c98354077f96015370506e5745a109 (diff)
downloadcowlib-20ada930c3996945fe2771518da05b5e7ae9b904.tar.gz
cowlib-20ada930c3996945fe2771518da05b5e7ae9b904.tar.bz2
cowlib-20ada930c3996945fe2771518da05b5e7ae9b904.zip
Add cow_http_hd:parse_accept/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')
-rw-r--r--include/cow_inline.hrl32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/cow_inline.hrl b/include/cow_inline.hrl
index 36a3558..82cc465 100644
--- a/include/cow_inline.hrl
+++ b/include/cow_inline.hrl
@@ -15,6 +15,38 @@
-ifndef(COW_INLINE_HRL).
-define(COW_INLINE_HRL, 1).
+%% IS_DIGIT(Character)
+
+-define(IS_DIGIT(C),
+ C >= $0, C =< $9
+).
+
+%% IS_TOKEN(Character)
+
+-define(IS_TOKEN(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;
+ C =:= $p; C =:= $q; C =:= $r; C =:= $s; C =:= $t;
+ C =:= $u; C =:= $v; C =:= $w; C =:= $x; C =:= $y;
+ C =:= $z;
+ 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;
+ C =:= $P; C =:= $Q; C =:= $R; C =:= $S; C =:= $T;
+ C =:= $U; C =:= $V; C =:= $W; C =:= $X; C =:= $Y;
+ C =:= $2;
+ C =:= $0; C =:= $1; C =:= $2; C =:= $3; C =:= $4;
+ C =:= $5; C =:= $6; C =:= $7; C =:= $8; C =:= $9;
+ C =:= $!; C =:= $#; C =:= $$; C =:= $%; C =:= $&;
+ C =:= $'; C =:= $*; C =:= $+; C =:= $-; C =:= $.;
+ C =:= $^; C =:= $_; C =:= $`; C =:= $|; C =:= $~
+).
+
+%% IS_VCHAR(Character)
+
+-define(IS_VCHAR(C), C =:= $\t; C > 31, C =/= 127).
+
%% INLINE_LOWERCASE(Function, Rest, Acc, ...)
%%
%% To be included at the end of a case block.