summaryrefslogtreecommitdiff
path: root/lib/http
diff options
context:
space:
mode:
authorLucas Gabriel Vuotto <lvuotto92@gmail.com>2017-11-01 16:53:26 -0300
committerOri Bernstein <ori@markovcorp.com>2017-11-14 13:50:39 -0800
commit83d26331a5419033927800760e8a59f1bd84d2b9 (patch)
treed5985e8e5a32e673f549fcaa8eb23b5335f4f74d /lib/http
parent8a662861ad3ded8e965ab43e5bc254dd7ee85815 (diff)
downloadmc-83d26331a5419033927800760e8a59f1bd84d2b9.tar.gz
Use new traits to implement hash tables
Signed-off-by: Lucas Gabriel Vuotto <lvuotto92@gmail.com>
Diffstat (limited to 'lib/http')
-rw-r--r--lib/http/parse.myr15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/http/parse.myr b/lib/http/parse.myr
index a91da3a..180b581 100644
--- a/lib/http/parse.myr
+++ b/lib/http/parse.myr
@@ -10,6 +10,19 @@ pkg http =
pkglocal const parsenumber : (str : byte[:]#, base : int -> std.option(int))
;;
+const strcaseeq = {a : byte[:], b : byte[:] -> bool
+ var ca, cb
+
+ while a.len == 0 || b.len == 0
+ (ca, a) = std.strstep(a)
+ (cb, b) = std.strstep(b)
+ if std.tolower(ca) != std.tolower(cb)
+ -> false
+ ;;
+ ;;
+ -> a.len == b.len
+}
+
const parsereq = {s
var r, err
@@ -221,7 +234,7 @@ const getenc = {r
const findhdr = {r, name
for (k, v) : r.hdrs
- if std.strcaseeq(k, name)
+ if strcaseeq(k, name)
-> `std.Some v
;;
;;