Changeset 55ccc9a0 for lib/http_client.c


Ignore:
Timestamp:
2012-09-22T11:52:01Z (8 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d0752e8
Parents:
daf544a
Message:

Solve a whole bunch of Twitter module crashes: Twitter responses seem to
be getting truncated sometimes. Treat this as an error in http_client
already instead of returning partial data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/http_client.c

    rdaf544a r55ccc9a0  
    198198        int evil_server = 0;
    199199        char buffer[2048];
    200         char *end1, *end2;
     200        char *end1, *end2, *s;
     201        size_t content_length;
    201202        int st;
    202203       
     
    481482        /* Assume that a closed connection means we're finished, this indeed
    482483           breaks with keep-alive connections and faulty connections. */
    483         req->finished = 1;
     484        /* req->finished = 1; */
    484485
    485486cleanup:
     
    488489        else
    489490                closesocket( req->fd );
     491       
     492        if( ( s = get_rfc822_header( req->reply_headers, "Content-Length", 0 ) ) &&
     493            sscanf( s, "%zd", &content_length ) == 1 )
     494        {
     495                if( content_length < req->body_size )
     496                {
     497                        req->status_code = -1;
     498                        g_free( req->status_string );
     499                        req->status_string = g_strdup( "Response truncated" );
     500                }
     501        }
     502        g_free( s );
    490503       
    491504        if( getenv( "BITLBEE_DEBUG" ) && req )
Note: See TracChangeset for help on using the changeset viewer.