Index: protocols/http_client.c
===================================================================
--- protocols/http_client.c	(revision ba9edaa568088900145bbd1004c864b7d408c38d)
+++ protocols/http_client.c	(revision 1b5ab3608488e0cbbc75933a59af1fa7e2ff60b0)
@@ -32,7 +32,7 @@
 
 
-static gboolean http_connected( gpointer data, int source, b_input_condition cond );
-static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond );
-static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond );
+static void http_connected( gpointer data, int source, GaimInputCondition cond );
+static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond );
+static void http_incoming_data( gpointer data, int source, GaimInputCondition cond );
 
 
@@ -71,7 +71,38 @@
 }
 
+void *http_dorequest_url( char *url_string, http_input_function func, gpointer data )
+{
+	url_t *url = g_new0( url_t, 1 );
+	char *request;
+	void *ret;
+	
+	if( !url_set( url, url_string ) )
+	{
+		g_free( url );
+		return NULL;
+	}
+	
+	if( url->proto != PROTO_HTTP && url->proto != PROTO_HTTPS )
+	{
+		g_free( url );
+		return NULL;
+	}
+	
+	request = g_strdup_printf( "GET %s HTTP/1.0\r\n"
+	                           "Host: %s\r\n"
+	                           "User-Agent: BitlBee " BITLBEE_VERSION " " ARCH "/" CPU "\r\n"
+	                           "\r\n", url->file, url->host );
+	
+	ret = http_dorequest( url->host, url->port,
+	                      url->proto == PROTO_HTTPS, request, func, data );
+	
+	g_free( url );
+	g_free( request );
+	return ret;
+}
+
 /* This one is actually pretty simple... Might get more calls if we can't write 
    the whole request at once. */
-static gboolean http_connected( gpointer data, int source, b_input_condition cond )
+static void http_connected( gpointer data, int source, GaimInputCondition cond )
 {
 	struct http_request *req = data;
@@ -82,5 +113,5 @@
 	
 	if( req->inpa > 0 )
-		b_event_remove( req->inpa );
+		gaim_input_remove( req->inpa );
 	
 	sock_make_nonblocking( req->fd );
@@ -117,11 +148,11 @@
 	
 	if( req->bytes_written < req->request_length )
-		req->inpa = b_input_add( source,
-		                         req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE,
-	        	                 http_connected, req );
-	else
-		req->inpa = b_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );
-	
-	return FALSE;
+		req->inpa = gaim_input_add( source,
+		                            req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE,
+	        	                    http_connected, req );
+	else
+		req->inpa = gaim_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );
+	
+	return;
 	
 error:
@@ -131,8 +162,8 @@
 	g_free( req );
 	
-	return FALSE;
+	return;
 }
 
-static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond )
+static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond )
 {
 	struct http_request *req = data;
@@ -146,5 +177,5 @@
 }
 
-static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond )
+static void http_incoming_data( gpointer data, int source, GaimInputCondition cond )
 {
 	struct http_request *req = data;
@@ -155,5 +186,5 @@
 	
 	if( req->inpa > 0 )
-		b_event_remove( req->inpa );
+		gaim_input_remove( req->inpa );
 	
 	if( req->ssl )
@@ -202,9 +233,9 @@
 	
 	/* There will be more! */
-	req->inpa = b_input_add( req->fd,
-	                         req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ,
-	                         http_incoming_data, req );
-	
-	return FALSE;
+	req->inpa = gaim_input_add( req->fd,
+	                            req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ,
+	                            http_incoming_data, req );
+	
+	return;
 
 got_reply:
@@ -222,18 +253,21 @@
 		evil_server = 1;
 	}
-	else
+	else if( end1 )
 	{
 		end1 += 2;
 	}
-	
-	if( end1 )
-	{
-		*end1 = 0;
-		
-		if( evil_server )
-			req->reply_body = end1 + 1;
-		else
-			req->reply_body = end1 + 2;
-	}
+	else
+	{
+		goto cleanup;
+	}
+	
+	*end1 = 0;
+	
+	if( evil_server )
+		req->reply_body = end1 + 1;
+	else
+		req->reply_body = end1 + 2;
+	
+	req->body_size = req->reply_headers + req->bytes_read - req->reply_body;
 	
 	if( ( end1 = strchr( req->reply_headers, ' ' ) ) != NULL )
@@ -362,5 +396,5 @@
 		req->reply_headers = req->reply_body = NULL;
 		
-		return FALSE;
+		return;
 	}
 	
@@ -380,5 +414,3 @@
 	g_free( req->reply_headers );
 	g_free( req );
-	
-	return FALSE;
 }
