X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fresp.c;h=9d7325bcd0199ba9f01f8653e97ab8d4b3b8b010;hb=2f43c22d6b0889674abff5e0876799b0e98606c1;hp=c1b74b9920802c27744933e28e8e4a1c53580e84;hpb=46e6630278db9fb3b7aa7150d28fcd90993a5cc9;p=ashd.git diff --git a/lib/resp.c b/lib/resp.c index c1b74b9..9d7325b 100644 --- a/lib/resp.c +++ b/lib/resp.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -73,7 +74,7 @@ void simpleerror(int fd, int code, char *msg, char *fmt, ...) bufcatstr(buf, "\r\n"); bufcatstr(buf, "\r\n"); free(tmp2); - out = fdopen(fd, "w"); + out = fdopen(dup(fd), "w"); fprintf(out, "HTTP/1.1 %i %s\n", code, msg); fprintf(out, "Content-Type: text/html\n"); fprintf(out, "Content-Length: %zi\n", buf.d); @@ -101,7 +102,7 @@ void stdredir(struct hthead *req, int fd, int code, char *dst) adst = sstrdup(dst); } else { if(*dst == '/') { - path = sstrdup(dst); + path = sstrdup(dst + 1); } else { if((*(url = req->url)) == '/') url++; @@ -115,7 +116,7 @@ void stdredir(struct hthead *req, int fd, int code, char *dst) free(path); } } - out = fdopen(fd, "w"); + out = fdopen(dup(fd), "w"); fprintf(out, "HTTP/1.1 %i Redirection\n", code); fprintf(out, "Content-Length: 0\n"); fprintf(out, "Location: %s\n", adst);