From 9df487d720a59bf8cb0dc4ccffc30ad8eb48256a Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 23 Nov 2003 18:19:35 +0000 Subject: add libhttpd --- src/libhttpd/gethead.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/libhttpd/gethead.c (limited to 'src/libhttpd/gethead.c') diff --git a/src/libhttpd/gethead.c b/src/libhttpd/gethead.c new file mode 100644 index 00000000..91abc7c9 --- /dev/null +++ b/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 0; + memmove(c->hstop, s, n); + c->hstop += n; + *c->hstop = '\0'; + if(p != nil) + return 1; + if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend) + return 0; + } +} -- cgit v1.2.3