diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-09-22 13:47:55 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-09-22 13:47:55 +0100 | 
| commit | 9c77fbf0850c364c31f80e30c54137252291ec91 (patch) | |
| tree | dad13ba8f43346dfbb5785580e730d92ca16c367 /lib/http_client.c | |
| parent | c6fc24a81fa14cea4b3f497bbbb0e6e65a3cc6d4 (diff) | |
| parent | 11ec07811cc41e1b244467d25772ef021be9db1b (diff) | |
Merge mainline.
Diffstat (limited to 'lib/http_client.c')
| -rw-r--r-- | lib/http_client.c | 19 | 
1 files changed, 16 insertions, 3 deletions
| diff --git a/lib/http_client.c b/lib/http_client.c index 98a99f7c..7ed539d0 100644 --- a/lib/http_client.c +++ b/lib/http_client.c @@ -72,7 +72,7 @@ struct http_request *http_dorequest( char *host, int port, int ssl, char *reques  	if( getenv( "BITLBEE_DEBUG" ) )  		printf( "About to send HTTP request:\n%s\n", req->request ); -	return( req ); +	return req;  }  struct http_request *http_dorequest_url( char *url_string, http_input_function func, gpointer data ) @@ -197,7 +197,8 @@ static gboolean http_incoming_data( gpointer data, int source, b_input_condition  	struct http_request *req = data;  	int evil_server = 0;  	char buffer[2048]; -	char *end1, *end2; +	char *end1, *end2, *s; +	size_t content_length;  	int st;  	if( req->inpa > 0 ) @@ -480,7 +481,7 @@ got_reply:  	/* Assume that a closed connection means we're finished, this indeed  	   breaks with keep-alive connections and faulty connections. */ -	req->finished = 1; +	/* req->finished = 1; */  cleanup:  	if( req->ssl ) @@ -488,6 +489,18 @@ cleanup:  	else  		closesocket( req->fd ); +	if( ( s = get_rfc822_header( req->reply_headers, "Content-Length", 0 ) ) && +	    sscanf( s, "%zd", &content_length ) == 1 ) +	{ +		if( content_length < req->body_size ) +		{ +			req->status_code = -1; +			g_free( req->status_string ); +			req->status_string = g_strdup( "Response truncated" ); +		} +	} +	g_free( s ); +	  	if( getenv( "BITLBEE_DEBUG" ) && req )  		printf( "Finishing HTTP request with status: %s\n",  		        req->status_string ? req->status_string : "NULL" ); | 
