Changeset 4ff0966 for protocols/http_client.c
- Timestamp:
- 2006-05-28T23:13:47Z (18 years ago)
- Branches:
- master
- Children:
- df417ca
- Parents:
- cdca30b (diff), 79b6213 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/http_client.c
rcdca30b r4ff0966 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; … … 337 375 going to use strcat(), whether you like it or not. :-) */ 338 376 339 /* First, find the GET/POST/whatever from the original request. */ 340 s = strchr( req->request, ' ' ); 377 sprintf( new_request, "GET %s HTTP/1.0", url->file ); 378 379 s = strstr( req->request, "\r\n" ); 341 380 if( s == NULL ) 342 381 { 382 req->status_string = g_strdup( "Error while rebuilding request string" ); 343 383 g_free( new_request ); 344 384 g_free( url ); … … 346 386 } 347 387 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 ); 388 strcat( new_request, s ); 361 389 new_host = g_strdup( url->host ); 362 390 new_port = url->port; … … 372 400 373 401 req->fd = -1; 374 req->ssl = 0;402 req->ssl = NULL; 375 403 376 404 if( new_proto == PROTO_HTTPS ) … … 390 418 if( error ) 391 419 { 420 req->status_string = g_strdup( "Connection problem during redirect" ); 392 421 g_free( new_request ); 393 422 goto cleanup; … … 418 447 g_free( req->request ); 419 448 g_free( req->reply_headers ); 449 g_free( req->status_string ); 420 450 g_free( req ); 421 451
Note: See TracChangeset
for help on using the changeset viewer.