diff options
author | erdgeist <> | 2009-03-17 23:57:20 +0000 |
---|---|---|
committer | erdgeist <> | 2009-03-17 23:57:20 +0000 |
commit | c7ed890222939ff9d9a3b575eb83f216ccfebe9e (patch) | |
tree | 09bcb2adbb64b2c3eb53bf20145262d13b258284 /ot_http.c | |
parent | a58bce83ad91fa264a79c9a9acc9358bb2aa5661 (diff) |
Fix white spaces
Introduce loading tracker states with -l
Alter tracker state to a human readable form
Diffstat (limited to 'ot_http.c')
-rw-r--r-- | ot_http.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -288,7 +288,7 @@ static ssize_t http_handle_scrape( const int64 sock, struct ot_workstruct *ws, c | |||
288 | 288 | ||
289 | /* No info_hash found? Inform user */ | 289 | /* No info_hash found? Inform user */ |
290 | if( !numwant ) HTTPERROR_400_PARAM; | 290 | if( !numwant ) HTTPERROR_400_PARAM; |
291 | 291 | ||
292 | /* Limit number of hashes to process */ | 292 | /* Limit number of hashes to process */ |
293 | if( numwant > OT_MAXMULTISCRAPE_COUNT ) | 293 | if( numwant > OT_MAXMULTISCRAPE_COUNT ) |
294 | numwant = OT_MAXMULTISCRAPE_COUNT; | 294 | numwant = OT_MAXMULTISCRAPE_COUNT; |
@@ -312,7 +312,7 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, | |||
312 | unsigned short port = htons(6881); | 312 | unsigned short port = htons(6881); |
313 | char *write_ptr; | 313 | char *write_ptr; |
314 | ssize_t len; | 314 | ssize_t len; |
315 | struct http_data *cookie = io_getcookie( sock ); | 315 | struct http_data *cookie = io_getcookie( sock ); |
316 | 316 | ||
317 | /* This is to hack around stupid clients that send "announce ?info_hash" */ | 317 | /* This is to hack around stupid clients that send "announce ?info_hash" */ |
318 | if( read_ptr[-1] != '?' ) { | 318 | if( read_ptr[-1] != '?' ) { |
@@ -412,6 +412,9 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, | |||
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
415 | /* XXX DEBUG */ | ||
416 | stats_issue_event( EVENT_ACCEPT, FLAG_TCP, (uintptr_t)ws->reply ); | ||
417 | |||
415 | /* Scanned whole query string */ | 418 | /* Scanned whole query string */ |
416 | if( !hash ) | 419 | if( !hash ) |
417 | return ws->reply_size = sprintf( ws->reply, "d14:failure reason80:Your client forgot to send your torrent's info_hash. Please upgrade your client.e" ); | 420 | return ws->reply_size = sprintf( ws->reply, "d14:failure reason80:Your client forgot to send your torrent's info_hash. Please upgrade your client.e" ); |
@@ -488,14 +491,14 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) { | |||
488 | */ | 491 | */ |
489 | reply_off = SUCCESS_HTTP_SIZE_OFF - snprintf( ws->outbuf, 0, "%zd", ws->reply_size ); | 492 | reply_off = SUCCESS_HTTP_SIZE_OFF - snprintf( ws->outbuf, 0, "%zd", ws->reply_size ); |
490 | ws->reply = ws->outbuf + reply_off; | 493 | ws->reply = ws->outbuf + reply_off; |
491 | 494 | ||
492 | /* 2. Now we sprintf our header so that sprintf writes its terminating '\0' exactly one byte before content starts. Complete | 495 | /* 2. Now we sprintf our header so that sprintf writes its terminating '\0' exactly one byte before content starts. Complete |
493 | packet size is increased by size of header plus one byte '\n', we will copy over '\0' in next step */ | 496 | packet size is increased by size of header plus one byte '\n', we will copy over '\0' in next step */ |
494 | ws->reply_size += 1 + sprintf( ws->reply, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: %zd\r\n\r", ws->reply_size ); | 497 | ws->reply_size += 1 + sprintf( ws->reply, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: %zd\r\n\r", ws->reply_size ); |
495 | 498 | ||
496 | /* 3. Finally we join both blocks neatly */ | 499 | /* 3. Finally we join both blocks neatly */ |
497 | ws->outbuf[ SUCCESS_HTTP_HEADER_LENGTH - 1 ] = '\n'; | 500 | ws->outbuf[ SUCCESS_HTTP_HEADER_LENGTH - 1 ] = '\n'; |
498 | 501 | ||
499 | http_senddata( sock, ws ); | 502 | http_senddata( sock, ws ); |
500 | return ws->reply_size; | 503 | return ws->reply_size; |
501 | } | 504 | } |