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);
}
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");
}
}
{
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;
}
}
}
sendstatus(headers, stdout);
sendheaders(headers, stdout);
- printf("\r\n");
+ printf("\n");
passdata(out, stdout);
return(0);
}
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;
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);
}
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);
}
}
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);