diff options
-rw-r--r-- | opentracker.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/opentracker.c b/opentracker.c index 2299844..17584ab 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -40,6 +40,9 @@ static char static_scratch[8192]; | |||
40 | #ifdef _DEBUG_FDS | 40 | #ifdef _DEBUG_FDS |
41 | static char fd_debug_space[0x10000]; | 41 | static char fd_debug_space[0x10000]; |
42 | #endif | 42 | #endif |
43 | #ifdef _DEBUG_HTTPERROR | ||
44 | static char debug_request[8192]; | ||
45 | #endif | ||
43 | 46 | ||
44 | static void carp(const char* routine) { | 47 | static void carp(const char* routine) { |
45 | buffer_puts(buffer_2,routine); | 48 | buffer_puts(buffer_2,routine); |
@@ -135,7 +138,7 @@ void httperror(int64 s,struct http_data* h,const char* title,const char* message | |||
135 | size_t reply_size = sprintf( static_scratch, "HTTP/1.0 %s\r\nContent-Type: text/html\r\nConnection: close\r\nContent-Length: %zd\r\n\r\n<title>%s</title>\n", | 138 | size_t reply_size = sprintf( static_scratch, "HTTP/1.0 %s\r\nContent-Type: text/html\r\nConnection: close\r\nContent-Length: %zd\r\n\r\n<title>%s</title>\n", |
136 | title, strlen(message)+strlen(title)+16-4,title+4); | 139 | title, strlen(message)+strlen(title)+16-4,title+4); |
137 | #ifdef _DEBUG_HTTPERROR | 140 | #ifdef _DEBUG_HTTPERROR |
138 | fprintf( stderr, "DEBUG: invalid request was: %s\n", (char*)array_start( &h->r ) ); | 141 | fprintf( stderr, "DEBUG: invalid request was: %s\n", debug_request ); |
139 | #endif | 142 | #endif |
140 | senddata(s,h,static_scratch,reply_size); | 143 | senddata(s,h,static_scratch,reply_size); |
141 | } | 144 | } |
@@ -169,6 +172,10 @@ void httpresponse(int64 s,struct http_data* h) | |||
169 | array_cat0(&h->r); | 172 | array_cat0(&h->r); |
170 | c = array_start(&h->r); | 173 | c = array_start(&h->r); |
171 | 174 | ||
175 | #ifdef _DEBUG_HTTPERROR | ||
176 | memcpy( debug_request, array_start(&h->r), array_bytes(&h->r) ); | ||
177 | #endif | ||
178 | |||
172 | if (byte_diff(c,4,"GET ")) { | 179 | if (byte_diff(c,4,"GET ")) { |
173 | e400: | 180 | e400: |
174 | return httperror(s,h,"400 Invalid Request","This server only understands GET."); | 181 | return httperror(s,h,"400 Invalid Request","This server only understands GET."); |
@@ -481,6 +488,10 @@ void handle_read( int64 clientsocket ) { | |||
481 | 488 | ||
482 | array_catb(&h->r,static_scratch,l); | 489 | array_catb(&h->r,static_scratch,l); |
483 | 490 | ||
491 | #ifdef _DEBUG_HTTPERROR | ||
492 | memcpy( debug_request, "500!\0", 5 ); | ||
493 | #endif | ||
494 | |||
484 | if( array_failed(&h->r)) | 495 | if( array_failed(&h->r)) |
485 | httperror(clientsocket,h,"500 Server Error","Request too long."); | 496 | httperror(clientsocket,h,"500 Server Error","Request too long."); |
486 | else if (array_bytes(&h->r)>8192) | 497 | else if (array_bytes(&h->r)>8192) |