summaryrefslogtreecommitdiff
path: root/lib/http
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-09-30 22:18:21 -0700
committerOri Bernstein <ori@eigenstate.org>2017-09-30 22:18:21 -0700
commit8672ce0c95bf5d6e6b721694bd0e5944d4af556b (patch)
treead54ebc4603c410cd9eb0b2f07cf133a701ff185 /lib/http
parent7cc7912b2834f9f5dde95412e5302f13fb82042c (diff)
downloadmc-8672ce0c95bf5d6e6b721694bd0e5944d4af556b.tar.gz
Replace bio.status(@t) with std.result(@t, bio.err)
It's more consistent.
Diffstat (limited to 'lib/http')
-rw-r--r--lib/http/client.myr17
-rw-r--r--lib/http/parse.myr29
-rw-r--r--lib/http/session.myr10
3 files changed, 20 insertions, 36 deletions
diff --git a/lib/http/client.myr b/lib/http/client.myr
index 4fdf481..770c233 100644
--- a/lib/http/client.myr
+++ b/lib/http/client.myr
@@ -180,9 +180,8 @@ const readlenbody = {s, r
buf = std.slalloc(r.len)
match bio.read(s.f, buf)
- | `bio.Err e: goto shortread
- | `bio.Eof: goto shortread
- | `bio.Ok rd:
+ | `std.Err e: goto shortread
+ | `std.Ok rd:
if rd.len != r.len
goto shortread
;;
@@ -215,13 +214,10 @@ const readchunkedbody = {s, r
| `std.Ok sz:
std.slgrow(&buf, buf.len + sz)
match bio.read(s.f, buf[len:len + sz])
- | `bio.Eof:
- std.slfree(buf)
- -> `std.Err `Eshort
- | `bio.Err e:
+ | `std.Err e:
std.slfree(buf)
-> `std.Err `Econn
- | `bio.Ok str:
+ | `std.Ok str:
if str.len != sz
std.slfree(buf)
-> `std.Err `Eshort
@@ -243,9 +239,8 @@ const checkendln = {s
var r
match bio.readln(s.f)
- | `bio.Err e: r = `std.Err `Econn
- | `bio.Eof: r = `std.Err `Econn
- | `bio.Ok crlf:
+ | `std.Err e: r = `std.Err `Econn
+ | `std.Ok crlf:
if std.strstrip(crlf).len == 0
r = `std.Ok void
else
diff --git a/lib/http/parse.myr b/lib/http/parse.myr
index d9f8b34..fabf7a2 100644
--- a/lib/http/parse.myr
+++ b/lib/http/parse.myr
@@ -23,13 +23,10 @@ const parsereq = {s
])
match bio.readln(s.f)
- | `bio.Err e:
- err = `Econn
- goto error
- | `bio.Eof:
+ | `std.Err e:
err = `Econn
goto error
- | `bio.Ok ln:
+ | `std.Ok ln:
match parsereqstatus(s, r, ln)
| `std.Ok void:
| `std.Err e:
@@ -42,13 +39,10 @@ const parsereq = {s
while true
match bio.readln(s.f)
- | `bio.Err e:
- err = `Econn
- goto error
- | `bio.Eof:
+ | `std.Err e:
err = `Econn
goto error
- | `bio.Ok ln:
+ | `std.Ok ln:
if std.strstrip(ln).len == 0
std.slfree(ln)
break
@@ -70,9 +64,8 @@ const parsereq = {s
const parseresp = {s, r : resp#
match bio.readln(s.f)
- | `bio.Err e: r.err = `std.Some `Econn
- | `bio.Eof: r.err = `std.Some `Econn
- | `bio.Ok ln:
+ | `std.Err _: r.err = `std.Some `Econn
+ | `std.Ok ln:
if !parserespstatus(s, r, ln)
std.slfree(ln)
-> false
@@ -82,9 +75,8 @@ const parseresp = {s, r : resp#
while true
match bio.readln(s.f)
- | `bio.Err e: r.err = `std.Some `Econn
- | `bio.Eof: r.err = `std.Some `Econn
- | `bio.Ok ln:
+ | `std.Err e: r.err = `std.Some `Econn
+ | `std.Ok ln:
if std.strstrip(ln).len == 0
std.slfree(ln)
break
@@ -203,9 +195,8 @@ const parsechunksz = {s
var ret, str
match bio.readln(s.f)
- | `bio.Eof: ret = `std.Err `Econn
- | `bio.Err e: ret = `std.Err `Econn
- | `bio.Ok ln:
+ | `std.Err e: ret = `std.Err `Econn
+ | `std.Ok ln:
str = ln
match parsenumber(&str, 16)
| `std.Some n: ret = `std.Ok (n : std.size)
diff --git a/lib/http/session.myr b/lib/http/session.myr
index 2b6f65a..4091165 100644
--- a/lib/http/session.myr
+++ b/lib/http/session.myr
@@ -58,9 +58,8 @@ const ioput = {s, fmt, args
;;
ap = std.vastart(&args)
match bio.putv(s.f, fmt, &ap)
- | `bio.Ok _: /* nothing */
- | `bio.Err _: s.err = true
- | `bio.Eof: s.err = true
+ | `std.Ok _: /* nothing */
+ | `std.Err _: s.err = true
;;
-> s.err
}
@@ -70,9 +69,8 @@ const iowrite = {s, buf
-> false
;;
match bio.write(s.f, buf)
- | `bio.Ok _: /* nothing */
- | `bio.Err _: s.err = true
- | `bio.Eof: s.err = true
+ | `std.Ok _: /* nothing */
+ | `std.Err _: s.err = true
;;
-> s.err
}