various bug fixes
This commit is contained in:
parent
4f48d1d4f7
commit
2e965b3324
12 changed files with 82 additions and 41 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue