Use new-style (CR-less) headers in responses.
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 20 Aug 2010 13:29:54 +0000 (15:29 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 20 Aug 2010 13:29:54 +0000 (15:29 +0200)
lib/resp.c
src/callcgi.c
src/debugsink.c
src/sendfile.c

index da354f9..63c8eca 100644 (file)
@@ -74,10 +74,10 @@ void simpleerror(int fd, int code, char *msg, char *fmt, ...)
     bufcatstr(buf, "</html>\r\n");
     free(tmp2);
     out = fdopen(fd, "w");
-    fprintf(out, "HTTP/1.1 %i %s\r\n", code, msg);
-    fprintf(out, "Content-Type: text/html\r\n");
-    fprintf(out, "Content-Length: %zi\r\n", buf.d);
-    fprintf(out, "\r\n");
+    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);
+    fprintf(out, "\n");
     fwrite(buf.b, 1, buf.d, out);
     fclose(out);
     buffree(buf);
index 70a97dd..9e7c21b 100644 (file)
@@ -258,13 +258,13 @@ static void sendstatus(char **headers, FILE *out)
     }
     if(status) {
        if(strchr(status, ' '))
-           fprintf(out, "HTTP/1.1 %s\r\n", status);
+           fprintf(out, "HTTP/1.1 %s\n", status);
        else
-           fprintf(out, "HTTP/1.1 %i %s\r\n", atoi(status), defstatus(atoi(status)));
+           fprintf(out, "HTTP/1.1 %i %s\n", atoi(status), defstatus(atoi(status)));
     } else if(location) {
-       fprintf(out, "HTTP/1.1 303 See Other\r\n");
+       fprintf(out, "HTTP/1.1 303 See Other\n");
     } else {
-       fprintf(out, "HTTP/1.1 200 OK\r\n");
+       fprintf(out, "HTTP/1.1 200 OK\n");
     }
 }
 
@@ -272,7 +272,7 @@ static void sendheaders(char **headers, FILE *out)
 {
     while(*headers) {
        if(**headers)
-           fprintf(out, "%s: %s\r\n", headers[0], headers[1]);
+           fprintf(out, "%s: %s\n", headers[0], headers[1]);
        headers += 2;
     }
 }
@@ -329,7 +329,7 @@ int main(int argc, char **argv, char **envp)
     }
     sendstatus(headers, stdout);
     sendheaders(headers, stdout);
-    printf("\r\n");
+    printf("\n");
     passdata(out, stdout);
     return(0);
 }
index eb389f3..dee8c98 100644 (file)
@@ -47,9 +47,9 @@ int main(int argc, char **argv)
        printf("%s %s %s %s %s\n", req->method, req->url, req->ver, req->rest, getheader(req, "x-ash-address"));
        out = fdopen(fd, "w");
        if(!strcmp(req->rest, "")) {
-           fprintf(out, "HTTP/1.1 200 OK\r\n");
-           fprintf(out, "Content-Type: text/html; charset=utf8\r\n");
-           fprintf(out, "\r\n");
+           fprintf(out, "HTTP/1.1 200 OK\n");
+           fprintf(out, "Content-Type: text/html; charset=utf8\n");
+           fprintf(out, "\n");
            fprintf(out, "<html>\n<body>\n<form action=\"/post\" method=\"post\">\n<input type=\"submit\" name=\"barda\" />\n</form>\n</body>\n</html>\n");
        } else if(!strcmp(req->rest, "post")) {
            nb = 0;
@@ -61,19 +61,19 @@ int main(int argc, char **argv)
                    break;
                nb += ret;
            }
-           fprintf(out, "HTTP/1.1 200 OK\r\n");
-           fprintf(out, "Content-Type: text/plain; charset=utf8\r\n");
-           fprintf(out, "\r\n");
+           fprintf(out, "HTTP/1.1 200 OK\n");
+           fprintf(out, "Content-Type: text/plain; charset=utf8\n");
+           fprintf(out, "\n");
            fprintf(out, "%i\n", (int)nb);
        } else if(!strcmp(req->rest, "inf")) {
-           fprintf(out, "HTTP/1.1 200 OK\r\n");
-           fprintf(out, "Content-Type: text/plain\r\n");
-           fprintf(out, "\r\n");
+           fprintf(out, "HTTP/1.1 200 OK\n");
+           fprintf(out, "Content-Type: text/plain\n");
+           fprintf(out, "\n");
            while(1)
                fprintf(out, "0123456789012345678901234567890123456789012345678901234567890123456789\n");
        } else {
-           fprintf(out, "HTTP/1.1 404 Not Found\r\n");
-           fprintf(out, "\r\n");
+           fprintf(out, "HTTP/1.1 404 Not Found\n");
+           fprintf(out, "\n");
        }
        fclose(out);
     }
index 601661b..48787fd 100644 (file)
@@ -120,10 +120,10 @@ static void checkcache(char *file, struct stat *sb)
     if((hdr = getenv("REQ_IF_MODIFIED_SINCE")) != NULL) {
        if(parsehttpdate(hdr) < sb->st_mtime)
            return;
-       printf("HTTP/1.1 304 Not Modified\r\n");
-       printf("Date: %s\r\n", fmthttpdate(time(NULL)));
-       printf("Content-Length: 0\r\n");
-       printf("\r\n");
+       printf("HTTP/1.1 304 Not Modified\n");
+       printf("Date: %s\n", fmthttpdate(time(NULL)));
+       printf("Content-Length: 0\n");
+       printf("\n");
        exit(0);
     }
 }
@@ -175,12 +175,12 @@ int main(int argc, char **argv)
     
     checkcache(file, &sb);
     
-    printf("HTTP/1.1 200 OK\r\n");
-    printf("Content-Type: %s\r\n", contype);
-    printf("Content-Length: %ji\r\n", (intmax_t)sb.st_size);
-    printf("Last-Modified: %s\r\n", fmthttpdate(sb.st_mtime));
-    printf("Date: %s\r\n", fmthttpdate(time(NULL)));
-    printf("\r\n");
+    printf("HTTP/1.1 200 OK\n");
+    printf("Content-Type: %s\n", contype);
+    printf("Content-Length: %ji\n", (intmax_t)sb.st_size);
+    printf("Last-Modified: %s\n", fmthttpdate(sb.st_mtime));
+    printf("Date: %s\n", fmthttpdate(time(NULL)));
+    printf("\n");
     fflush(stdout);
     if(strcasecmp(argv[optind], "head"))
        passdata(fd, 1);