Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
htparser: Add a `Server' header if none previously present.
[ashd.git]
/
src
/
htparser.c
diff --git
a/src/htparser.c
b/src/htparser.c
index
503df99
..
33ceb49
100644
(file)
--- 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((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(!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;
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(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);
writeresp(in, resp);
fprintf(in, "\r\n");
dlen = passdata(out, in, -1);