- Timestamp:
- 2006-05-26T18:32:50Z (19 years ago)
- Branches:
- master
- Children:
- fe23720
- Parents:
- 6048744
- Location:
- protocols
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/http_client.c
r6048744 r7deb447 157 157 158 158 error: 159 req->status_string = g_strdup( "Error while writing HTTP request" ); 160 159 161 req->func( req ); 160 162 … … 216 218 if( !sockerr_again() ) 217 219 { 220 req->status_string = g_strdup( strerror( errno ) ); 218 221 goto cleanup; 219 222 } … … 243 246 support... */ 244 247 if( req->bytes_read == 0 ) 248 { 249 req->status_string = g_strdup( "Empty HTTP reply" ); 245 250 goto cleanup; 251 } 246 252 247 253 /* Zero termination is very convenient. */ … … 264 270 else 265 271 { 272 req->status_string = g_strdup( "Malformed HTTP reply" ); 266 273 goto cleanup; 267 274 } … … 279 286 { 280 287 if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 ) 288 { 289 req->status_string = g_strdup( "Can't parse status code" ); 281 290 req->status_code = -1; 282 } 283 else 284 { 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" ); 285 313 req->status_code = -1; 286 314 } … … 291 319 int error = 0, new_port, new_proto; 292 320 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 293 325 loc = strstr( req->reply_headers, "\nLocation: " ); 294 326 if( loc == NULL ) /* We can't handle this redirect... */ 327 { 328 req->status_string = g_strdup( "Can't locate Location: header" ); 295 329 goto cleanup; 330 } 296 331 297 332 loc += 11; … … 310 345 don't need this yet anyway, I won't implement it. */ 311 346 347 req->status_string = g_strdup( "Can't handle recursive redirects" ); 348 312 349 goto cleanup; 313 350 } … … 327 364 if( !url_set( url, loc ) ) 328 365 { 366 req->status_string = g_strdup( "Malformed redirect URL" ); 329 367 g_free( url ); 330 368 goto cleanup; … … 341 379 if( s == NULL ) 342 380 { 381 req->status_string = g_strdup( "Error while rebuilding request string" ); 343 382 g_free( new_request ); 344 383 g_free( url ); … … 353 392 if( s == NULL ) 354 393 { 394 req->status_string = g_strdup( "Error while rebuilding request string" ); 355 395 g_free( new_request ); 356 396 g_free( url ); … … 372 412 373 413 req->fd = -1; 374 req->ssl = 0;414 req->ssl = NULL; 375 415 376 416 if( new_proto == PROTO_HTTPS ) … … 390 430 if( error ) 391 431 { 432 req->status_string = g_strdup( "Connection problem during redirect" ); 392 433 g_free( new_request ); 393 434 goto cleanup; … … 418 459 g_free( req->request ); 419 460 g_free( req->reply_headers ); 461 g_free( req->status_string ); 420 462 g_free( req ); 421 463 } -
protocols/http_client.h
r6048744 r7deb447 37 37 int request_length; 38 38 int status_code; 39 char *status_string; 39 40 char *reply_headers; 40 41 char *reply_body;
Note: See TracChangeset
for help on using the changeset viewer.