aboutsummaryrefslogtreecommitdiff
path: root/src/libhttpd
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-05-05 04:22:16 +0000
committerrsc <devnull@localhost>2004-05-05 04:22:16 +0000
commit2e965b3324b32be00a2193bf304dcb936f02824b (patch)
treec183e68a04ee42308f493face299cb4cc4c559ec /src/libhttpd
parent4f48d1d4f72b1986ba6df3ccd9db62cfa1ef3df9 (diff)
downloadplan9port-2e965b3324b32be00a2193bf304dcb936f02824b.tar.gz
plan9port-2e965b3324b32be00a2193bf304dcb936f02824b.tar.bz2
plan9port-2e965b3324b32be00a2193bf304dcb936f02824b.zip
various bug fixes
Diffstat (limited to 'src/libhttpd')
-rw-r--r--src/libhttpd/gethead.c11
-rw-r--r--src/libhttpd/hio.c6
-rw-r--r--src/libhttpd/parse.c2
-rw-r--r--src/libhttpd/parsereq.c4
4 files changed, 9 insertions, 14 deletions
diff --git a/src/libhttpd/gethead.c b/src/libhttpd/gethead.c
index 5983345e..0677cc8f 100644
--- a/src/libhttpd/gethead.c
+++ b/src/libhttpd/gethead.c
@@ -15,15 +15,11 @@ hgethead(HConnect *c, int many)
int n;
hin = &c->hin;
-fprint(2, "hgethead top %p - %p\n", hin->pos, hin->stop);
for(;;){
s = (char*)hin->pos;
pp = s;
-fprint(2, "hgethead %p - %p\n", pp, hin->stop);
while(p = memchr(pp, '\n', (char*)hin->stop - pp)){
-fprint(2, "hgethead %p - %p newline at %p %d\n", pp, hin->stop, p, *pp);
if(!many || p == pp || (p == pp + 1 && *pp == '\r')){
-fprint(2, "breaking\n");
pp = p + 1;
break;
}
@@ -32,14 +28,13 @@ fprint(2, "breaking\n");
hin->pos = (uchar*)pp;
n = pp - s;
if(c->hstop + n > &c->header[HBufSize])
- return 0;
+ return -1;
memmove(c->hstop, s, n);
c->hstop += n;
*c->hstop = '\0';
-fprint(2, "p %p\n", p);
if(p != nil)
- return 1;
- if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend)
return 0;
+ if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend)
+ return -1;
}
}
diff --git a/src/libhttpd/hio.c b/src/libhttpd/hio.c
index 34d3a3a2..3561b681 100644
--- a/src/libhttpd/hio.c
+++ b/src/libhttpd/hio.c
@@ -281,7 +281,7 @@ hload(Hio *h, char *buf)
s = strchr(hstates, buf[0]);
if(s == nil)
- return 0;
+ return -1;
h->state = s - hstates;
s = strchr(hxfers, buf[1]);
@@ -300,13 +300,13 @@ hload(Hio *h, char *buf)
}
*t++ = c;
if(t >= stop)
- return 0;
+ return -1;
}
*t = '\0';
h->pos = h->start;
h->stop = t;
h->seek = 0;
- return 1;
+ return 0;
}
void
diff --git a/src/libhttpd/parse.c b/src/libhttpd/parse.c
index 5fd4092a..8e8364b0 100644
--- a/src/libhttpd/parse.c
+++ b/src/libhttpd/parse.c
@@ -198,7 +198,7 @@ hparseheaders(HConnect *c, int timeout)
memset(&h, 0, sizeof(h));
h.c = c;
alarm(timeout);
- if(!hgethead(c, 1))
+ if(hgethead(c, 1) < 0)
return -1;
alarm(0);
h.hstart = c->hpos;
diff --git a/src/libhttpd/parsereq.c b/src/libhttpd/parsereq.c
index 7ef63413..94237988 100644
--- a/src/libhttpd/parsereq.c
+++ b/src/libhttpd/parsereq.c
@@ -41,8 +41,8 @@ hparsereq(HConnect *c, int timeout)
* only works for http/1.1 or later.
*/
alarm(timeout);
- if(!hgethead(c, 0))
- return 0;
+ if(hgethead(c, 0) < 0)
+ return -1;
alarm(0);
c->reqtime = time(nil);
c->req.meth = getword(c);