- Timestamp:
- 2011-12-11T16:38:02Z (13 years ago)
- Branches:
- master
- Children:
- d717020
- Parents:
- 877686b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/http_client.c
r877686b r3f808ca 69 69 req->request_length = strlen( request ); 70 70 req->redir_ttl = 3; 71 72 if( getenv( "BITLBEE_DEBUG" ) ) 73 printf( "About to send HTTP request:\n%s\n", req->request ); 71 74 72 75 return( req ); … … 280 283 281 284 if( getenv( "BITLBEE_DEBUG" ) ) 282 printf( "HTTP response headers:\n%s ", req->reply_headers );285 printf( "HTTP response headers:\n%s\n", req->reply_headers ); 283 286 284 287 if( evil_server ) … … 320 323 } 321 324 322 if( ( req->status_code >= 301 && req->status_code <= 303 ) && req->redir_ttl-- > 0 ) 325 if( ( ( req->status_code >= 301 && req->status_code <= 303 ) || 326 req->status_code == 307 ) && req->redir_ttl-- > 0 ) 323 327 { 324 328 char *loc, *new_request, *new_host; … … 391 395 Always perform a GET request unless we received a 301. 303 was 392 396 meant for this but it's HTTP/1.1-only and we're specifically 393 speaking HTTP/1.0. */ 394 new_method = req->status_code != 301 || req->request[0] == 'G' ? "GET" : "POST"; 397 speaking HTTP/1.0. ... 398 399 Well except someone at identi.ca's didn't bother reading any 400 RFCs and just return HTTP/1.1-specific status codes to HTTP/1.0 401 requests. Fuckers. So here we are, handle 301..303,307. */ 402 if( strncmp( req->request, "GET", 3 ) == 0 ) 403 /* GETs never become POSTs. */ 404 new_method = "GET"; 405 else if( req->status_code == 302 || req->status_code == 303 ) 406 /* 302 de-facto becomes GET, 303 as specified by RFC 2616#10.3.3 */ 407 new_method = "GET"; 408 else 409 /* 301 de-facto should stay POST, 307 specifally RFC 2616#10.3.8 */ 410 new_method = "POST"; 395 411 396 412 /* Okay, this isn't fun! We have to rebuild the request... :-( */ … … 419 435 420 436 if( getenv( "BITLBEE_DEBUG" ) ) 421 printf( "New headers for redirected HTTP request:\n%s ", new_request );437 printf( "New headers for redirected HTTP request:\n%s\n", new_request ); 422 438 423 439 if( new_proto == PROTO_HTTPS ) … … 463 479 464 480 if( getenv( "BITLBEE_DEBUG" ) && req ) 465 printf( "Finishing HTTP request with status: %s ",481 printf( "Finishing HTTP request with status: %s\n", 466 482 req->status_string ? req->status_string : "NULL" ); 467 483
Note: See TracChangeset
for help on using the changeset viewer.