summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
authordenis <>2007-01-24 20:13:30 +0000
committerdenis <>2007-01-24 20:13:30 +0000
commit4fc8dd75be7e511823d6ff529411896b1b5e1c7e (patch)
tree051d4d695decd74735d31fddee2439b3f5818d04 /opentracker.c
parent2d0215d79307deeaecff5494da115adafde5bccc (diff)
Copy request before expanding url-encoded bytes
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c13
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
41static char fd_debug_space[0x10000]; 41static char fd_debug_space[0x10000];
42#endif 42#endif
43#ifdef _DEBUG_HTTPERROR
44static char debug_request[8192];
45#endif
43 46
44static void carp(const char* routine) { 47static 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 ")) {
173e400: 180e400:
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)