aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-12-29 17:21:16 +0100
committerLoïc Hoguin <[email protected]>2014-12-29 17:24:04 +0100
commit1c732125bfd12fb3a25997f93cdf9e418666bddb (patch)
tree08bdd4c839aef37e52181d9ca615d69da894e83a /include
parent779f4ad51c665092b1da5c8028dad6d62a5f76f0 (diff)
downloadcowlib-1c732125bfd12fb3a25997f93cdf9e418666bddb.tar.gz
cowlib-1c732125bfd12fb3a25997f93cdf9e418666bddb.tar.bz2
cowlib-1c732125bfd12fb3a25997f93cdf9e418666bddb.zip
Add cow_http_hd:parse_host/1, remove cow_http:parse_fullhost/1
From RFC7230 and RFC3986. The new function now validates that the characters are correct, but does not go as far as validate segment sizes or number of segments. Its main purpose is still to split host and port.
Diffstat (limited to 'include')
-rw-r--r--include/cow_inline.hrl30
1 files changed, 26 insertions, 4 deletions
diff --git a/include/cow_inline.hrl b/include/cow_inline.hrl
index 649ff79..3abb018 100644
--- a/include/cow_inline.hrl
+++ b/include/cow_inline.hrl
@@ -32,6 +32,10 @@
C =:= $Z
).
+%% IS_ALPHANUM(Character)
+
+-define(IS_ALPHANUM(C), ?IS_ALPHA(C) orelse ?IS_DIGIT(C)).
+
%% IS_CHAR(Character)
-define(IS_CHAR(C), C > 0, C < 128).
@@ -43,14 +47,19 @@
C =:= $5 orelse C =:= $6 orelse C =:= $7 orelse C =:= $8 orelse C =:= $9
).
-%% IS_ALPHANUM(Character)
-
--define(IS_ALPHANUM(C), ?IS_ALPHA(C) orelse ?IS_DIGIT(C)).
-
%% IS_ETAGC(Character)
-define(IS_ETAGC(C), C =:= 16#21; C >= 16#23, C =/= 16#7f).
+%% IS_HEX(Character)
+
+-define(IS_HEX(C),
+ ?IS_DIGIT(C) orelse
+ C =:= $a orelse C =:= $b orelse C =:= $c orelse
+ C =:= $d orelse C =:= $e orelse C =:= $f orelse
+ C =:= $A orelse C =:= $B orelse C =:= $C orelse
+ C =:= $D orelse C =:= $E orelse C =:= $F).
+
%% IS_TOKEN(Character)
-define(IS_TOKEN(C),
@@ -60,6 +69,19 @@
orelse C =:= $^ orelse C =:= $_ orelse C =:= $` orelse C =:= $| orelse C =:= $~
).
+%% IS_URI_UNRESERVED(Character)
+
+-define(IS_URI_UNRESERVED(C),
+ ?IS_ALPHA(C) orelse ?IS_DIGIT(C) orelse
+ C =:= $- orelse C =:= $. orelse C =:= $_ orelse C =:= $~).
+
+%% IS_URI_SUB_DELIMS(Character)
+
+-define(IS_URI_SUB_DELIMS(C),
+ C =:= $! orelse C =:= $$ orelse C =:= $& orelse C =:= $' orelse
+ C =:= $( orelse C =:= $) orelse C =:= $* orelse C =:= $+ orelse
+ C =:= $, orelse C =:= $; orelse C =:= $=).
+
%% IS_VCHAR(Character)
-define(IS_VCHAR(C), C =:= $\t; C > 31, C < 127).