From e5888a1ffdae813d7575f5fb02275c6bb07e5199 Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Wed, 30 Mar 2011 15:46:40 +0300 Subject: Import sources from 2011-03-30 iso image --- sys/src/libhttpd/gethead.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 sys/src/libhttpd/gethead.c (limited to 'sys/src/libhttpd/gethead.c') diff --git a/sys/src/libhttpd/gethead.c b/sys/src/libhttpd/gethead.c new file mode 100755 index 000000000..0677cc8f3 --- /dev/null +++ b/sys/src/libhttpd/gethead.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +/* + * read in some header lines, either one or all of them. + * copy results into header log buffer. + */ +int +hgethead(HConnect *c, int many) +{ + Hio *hin; + char *s, *p, *pp; + int n; + + hin = &c->hin; + for(;;){ + s = (char*)hin->pos; + pp = s; + while(p = memchr(pp, '\n', (char*)hin->stop - pp)){ + if(!many || p == pp || (p == pp + 1 && *pp == '\r')){ + pp = p + 1; + break; + } + pp = p + 1; + } + hin->pos = (uchar*)pp; + n = pp - s; + if(c->hstop + n > &c->header[HBufSize]) + return -1; + memmove(c->hstop, s, n); + c->hstop += n; + *c->hstop = '\0'; + if(p != nil) + return 0; + if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend) + return -1; + } +} -- cgit v1.2.3