Changes in protocols/http_client.c [fe23720:0602496]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/http_client.c
rfe23720 r0602496 157 157 158 158 error: 159 req->status_string = g_strdup( "Error while writing HTTP request" );160 161 159 req->func( req ); 162 160 … … 218 216 if( !sockerr_again() ) 219 217 { 220 req->status_string = g_strdup( strerror( errno ) );221 218 goto cleanup; 222 219 } … … 246 243 support... */ 247 244 if( req->bytes_read == 0 ) 248 {249 req->status_string = g_strdup( "Empty HTTP reply" );250 245 goto cleanup; 251 }252 246 253 247 /* Zero termination is very convenient. */ … … 270 264 else 271 265 { 272 req->status_string = g_strdup( "Malformed HTTP reply" );273 266 goto cleanup; 274 267 } … … 286 279 { 287 280 if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 ) 288 {289 req->status_string = g_strdup( "Can't parse status code" );290 281 req->status_code = -1; 291 } 292 else 293 { 294 char *eol; 295 296 if( evil_server ) 297 eol = strchr( end1, '\n' ); 298 else 299 eol = strchr( end1, '\r' ); 300 301 req->status_string = g_strndup( end1 + 1, eol - end1 - 1 ); 302 303 /* Just to be sure... */ 304 if( ( eol = strchr( req->status_string, '\r' ) ) ) 305 *eol = 0; 306 if( ( eol = strchr( req->status_string, '\n' ) ) ) 307 *eol = 0; 308 } 309 } 310 else 311 { 312 req->status_string = g_strdup( "Can't locate status code" ); 282 } 283 else 284 { 313 285 req->status_code = -1; 314 286 } … … 319 291 int error = 0, new_port, new_proto; 320 292 321 /* We might fill it again, so let's not leak any memory. */322 g_free( req->status_string );323 req->status_string = NULL;324 325 293 loc = strstr( req->reply_headers, "\nLocation: " ); 326 294 if( loc == NULL ) /* We can't handle this redirect... */ 327 {328 req->status_string = g_strdup( "Can't locate Location: header" );329 295 goto cleanup; 330 }331 296 332 297 loc += 11; … … 345 310 don't need this yet anyway, I won't implement it. */ 346 311 347 req->status_string = g_strdup( "Can't handle recursive redirects" );348 349 312 goto cleanup; 350 313 } … … 364 327 if( !url_set( url, loc ) ) 365 328 { 366 req->status_string = g_strdup( "Malformed redirect URL" );367 329 g_free( url ); 368 330 goto cleanup; … … 375 337 going to use strcat(), whether you like it or not. :-) */ 376 338 377 sprintf( new_request, "GET %s HTTP/1.0", url->file ); 378 379 s = strstr( req->request, "\r\n" ); 339 /* First, find the GET/POST/whatever from the original request. */ 340 s = strchr( req->request, ' ' ); 380 341 if( s == NULL ) 381 342 { 382 req->status_string = g_strdup( "Error while rebuilding request string" );383 343 g_free( new_request ); 384 344 g_free( url ); … … 386 346 } 387 347 388 strcat( new_request, s ); 348 *s = 0; 349 sprintf( new_request, "%s %s HTTP/1.0\r\n", req->request, url->file ); 350 *s = ' '; 351 352 s = strstr( req->request, "\r\n" ); 353 if( s == NULL ) 354 { 355 g_free( new_request ); 356 g_free( url ); 357 goto cleanup; 358 } 359 360 strcat( new_request, s + 2 ); 389 361 new_host = g_strdup( url->host ); 390 362 new_port = url->port; … … 400 372 401 373 req->fd = -1; 402 req->ssl = NULL;374 req->ssl = 0; 403 375 404 376 if( new_proto == PROTO_HTTPS ) … … 418 390 if( error ) 419 391 { 420 req->status_string = g_strdup( "Connection problem during redirect" );421 392 g_free( new_request ); 422 393 goto cleanup; … … 447 418 g_free( req->request ); 448 419 g_free( req->reply_headers ); 449 g_free( req->status_string );450 420 g_free( req ); 451 421 }
Note: See TracChangeset
for help on using the changeset viewer.