Changeset 55ccc9a0 for lib


Ignore:
Timestamp:
2012-09-22T11:52:01Z (7 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.

Location:
lib
Files:
4 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 )
  • lib/http_client.h

    rdaf544a r55ccc9a0  
    5959        char *reply_body;
    6060        int body_size;          /* The number of bytes in reply_body. */
    61         int finished;           /* Set to non-0 if the request was completed
     61        /* int finished;          Set to non-0 if the request was completed
    6262                                   successfully. */
    6363        int redir_ttl;          /* You can set it to 0 if you don't want
  • lib/misc.c

    rdaf544a r55ccc9a0  
    730730}
    731731
    732 char *get_rfc822_header( char *text, char *header, int len )
     732char *get_rfc822_header( const char *text, const char *header, int len )
    733733{
    734734        int hlen = strlen( header ), i;
    735         char *ret;
     735        const char *ret;
    736736       
    737737        if( text == NULL )
  • lib/misc.h

    rdaf544a r55ccc9a0  
    6868G_MODULE_EXPORT int md5_verify_password( char *password, char *hash );
    6969G_MODULE_EXPORT char **split_command_parts( char *command );
    70 G_MODULE_EXPORT char *get_rfc822_header( char *text, char *header, int len );
     70G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len );
    7171
    7272#endif
Note: See TracChangeset for help on using the changeset viewer.