From 20ada930c3996945fe2771518da05b5e7ae9b904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 13 Dec 2014 11:13:05 +0200 Subject: 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. --- include/cow_inline.hrl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'include') 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. -- cgit v1.2.3