tinywebd
diff src/http.c @ 2:7bb4c2a0a360
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 15 Apr 2015 23:44:22 +0300 |
parents | f425a9805d17 |
children | 852a745503cf |
line diff
1.1 --- a/src/http.c Tue Apr 14 08:32:51 2015 +0300 1.2 +++ b/src/http.c Wed Apr 15 23:44:22 2015 +0300 1.3 @@ -1,5 +1,28 @@ 1.4 #include "http.h" 1.5 1.6 +int http_parse_header(struct http_req_header *hdr, const char *buf, int bufsz) 1.7 +{ 1.8 + int i, nlines = 0; 1.9 + char *endhdr; 1.10 + char *rqline = 0; 1.11 + 1.12 + for(i=1; i<bufsz; i++) { 1.13 + if(buf[i] == '\n' && buf[i - 1] == '\r') { 1.14 + if(!rqline) { 1.15 + rqline = alloca(i); 1.16 + memcpy(rqline, buf, i - 1); 1.17 + rqline[i - 1] = 0; 1.18 + } 1.19 + ++nlines; 1.20 + } 1.21 + } 1.22 + 1.23 + if(!rqline) 1.24 + return -1; 1.25 + 1.26 + 1.27 +} 1.28 + 1.29 const char *http_strmsg(int code) 1.30 { 1.31 static const char **msgxxx[] = {