Timeout reading header was a horrible idea.

This commit is contained in:
Neale Pickett 2012-03-19 22:10:49 -05:00
parent 49f6374ff0
commit 81d2a1a5d7
2 changed files with 1 additions and 13 deletions

12
eris.c
View File

@ -98,7 +98,6 @@ char *path;
int http_version; int http_version;
char *content_type; char *content_type;
size_t content_length; size_t content_length;
int header_sent;
off_t range_start, range_end; off_t range_start, range_end;
time_t ims = 0; time_t ims = 0;
@ -144,7 +143,6 @@ dolog(int code, off_t len)
void void
header(unsigned int code, const char *httpcomment) header(unsigned int code, const char *httpcomment)
{ {
header_sent = 1;
printf("HTTP/1.%d %u %s\r\n", http_version, code, httpcomment); printf("HTTP/1.%d %u %s\r\n", http_version, code, httpcomment);
printf("Server: " FNORD "\r\n"); printf("Server: " FNORD "\r\n");
printf("Connection: %s\r\n", keepalive?"keep-alive":"close"); printf("Connection: %s\r\n", keepalive?"keep-alive":"close");
@ -521,7 +519,6 @@ handle_request()
range_end = 0; range_end = 0;
content_type = NULL; content_type = NULL;
content_length = 0; content_length = 0;
header_sent = 0;
alarm(READTIMEOUT); alarm(READTIMEOUT);
@ -749,14 +746,6 @@ handle_request()
return; return;
} }
void
sigalarm(int sig)
{
if (! header_sent) {
badrequest(408, "Request Timeout", "You are being too slow.");
}
}
int int
main(int argc, char *argv[], const char *const *envp) main(int argc, char *argv[], const char *const *envp)
{ {
@ -767,7 +756,6 @@ main(int argc, char *argv[], const char *const *envp)
setbuffer(stdout, stdout_buf, sizeof stdout_buf); setbuffer(stdout, stdout_buf, sizeof stdout_buf);
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
signal(SIGALRM, sigalarm);
get_ucspi_env(); get_ucspi_env();
while (1) { while (1) {

View File

@ -193,7 +193,7 @@ printf 'GET /mongo.cgi HTTP/1.0\r\n\r\n' | $HTTPD_CGI 2>/dev/null | grep -q jame
H "Timeouts" H "Timeouts"
title "Read timeout" title "Read timeout"
(sleep 2.1; echo) | $HTTPD 2>&1 | grep -c 'HTTP/1.. 408 \|.null. 408' | grep -q 2 && pass || fail (sleep 2.1; printf 'GET / HTTP/1.0\r\n\r\n') | $HTTPD 2>/dev/null | grep -q '.' && fail || pass