Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/http_client.c

    rfe23720 r0602496  
    157157       
    158158error:
    159         req->status_string = g_strdup( "Error while writing HTTP request" );
    160        
    161159        req->func( req );
    162160       
     
    218216                        if( !sockerr_again() )
    219217                        {
    220                                 req->status_string = g_strdup( strerror( errno ) );
    221218                                goto cleanup;
    222219                        }
     
    246243           support... */
    247244        if( req->bytes_read == 0 )
    248         {
    249                 req->status_string = g_strdup( "Empty HTTP reply" );
    250245                goto cleanup;
    251         }
    252246       
    253247        /* Zero termination is very convenient. */
     
    270264        else
    271265        {
    272                 req->status_string = g_strdup( "Malformed HTTP reply" );
    273266                goto cleanup;
    274267        }
     
    286279        {
    287280                if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 )
    288                 {
    289                         req->status_string = g_strdup( "Can't parse status code" );
    290281                        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        {
    313285                req->status_code = -1;
    314286        }
     
    319291                int error = 0, new_port, new_proto;
    320292               
    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                
    325293                loc = strstr( req->reply_headers, "\nLocation: " );
    326294                if( loc == NULL ) /* We can't handle this redirect... */
    327                 {
    328                         req->status_string = g_strdup( "Can't locate Location: header" );
    329295                        goto cleanup;
    330                 }
    331296               
    332297                loc += 11;
     
    345310                           don't need this yet anyway, I won't implement it. */
    346311                       
    347                         req->status_string = g_strdup( "Can't handle recursive redirects" );
    348                        
    349312                        goto cleanup;
    350313                }
     
    364327                        if( !url_set( url, loc ) )
    365328                        {
    366                                 req->status_string = g_strdup( "Malformed redirect URL" );
    367329                                g_free( url );
    368330                                goto cleanup;
     
    375337                           going to use strcat(), whether you like it or not. :-) */
    376338                       
    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, ' ' );
    380341                        if( s == NULL )
    381342                        {
    382                                 req->status_string = g_strdup( "Error while rebuilding request string" );
    383343                                g_free( new_request );
    384344                                g_free( url );
     
    386346                        }
    387347                       
    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 );
    389361                        new_host = g_strdup( url->host );
    390362                        new_port = url->port;
     
    400372               
    401373                req->fd = -1;
    402                 req->ssl = NULL;
     374                req->ssl = 0;
    403375               
    404376                if( new_proto == PROTO_HTTPS )
     
    418390                if( error )
    419391                {
    420                         req->status_string = g_strdup( "Connection problem during redirect" );
    421392                        g_free( new_request );
    422393                        goto cleanup;
     
    447418        g_free( req->request );
    448419        g_free( req->reply_headers );
    449         g_free( req->status_string );
    450420        g_free( req );
    451421}
Note: See TracChangeset for help on using the changeset viewer.