X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fhtparser.c;h=33ceb4990468fc1a7c5bcb9fd1847ec2c4777659;hb=1c3e01675acafadd2b44d54b541a57de5b5031f1;hp=503df99a719ffda1c859d19c0d929dd0745f88dc;hpb=6a7a868e28e79f5502cc4b37578c263f640439c8;p=ashd.git diff --git a/src/htparser.c b/src/htparser.c index 503df99..33ceb49 100644 --- a/src/htparser.c +++ b/src/htparser.c @@ -272,11 +272,17 @@ void serve(FILE *in, struct conn *conn) if((resp = parseresp(out)) == NULL) break; replstr(&resp->ver, req->ver); + + if(!getheader(resp, "server")) + headappheader(resp, "Server", sprintf3("ashd/%s", VERSION)); if(!strcmp(req->ver, "HTTP/1.0")) { writeresp(in, resp); fprintf(in, "\r\n"); - if((hd = getheader(resp, "content-length")) != NULL) { + if(!strcasecmp(req->method, "head")) { + if(!hasheader(req, "connection", "keep-alive")) + break; + } else if((hd = getheader(resp, "content-length")) != NULL) { dlen = passdata(out, in, -1); if(dlen != atoo(hd)) break; @@ -289,7 +295,10 @@ void serve(FILE *in, struct conn *conn) if(hasheader(req, "connection", "close") || hasheader(resp, "connection", "close")) break; } else if(!strcmp(req->ver, "HTTP/1.1")) { - if((hd = getheader(resp, "content-length")) != NULL) { + if(!strcasecmp(req->method, "head")) { + writeresp(in, resp); + fprintf(in, "\r\n"); + } else if((hd = getheader(resp, "content-length")) != NULL) { writeresp(in, resp); fprintf(in, "\r\n"); dlen = passdata(out, in, -1);