diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-17 15:15:20 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-17 15:15:20 +0200 |
commit | 0790644bf8ccfbb1f09f4e7209fc18c2e97f10d8 (patch) | |
tree | 194268bffe26f55bd78bf62b1005563b327a4073 | |
parent | 5a348c3164f5f2d1a1f759c01e8bc7df2ad0dadb (diff) |
Added http_dorequest_url().
-rw-r--r-- | protocols/http_client.c | 31 | ||||
-rw-r--r-- | protocols/http_client.h | 1 |
2 files changed, 32 insertions, 0 deletions
diff --git a/protocols/http_client.c b/protocols/http_client.c index 9417e200..893ba551 100644 --- a/protocols/http_client.c +++ b/protocols/http_client.c @@ -70,6 +70,37 @@ void *http_dorequest( char *host, int port, int ssl, char *request, http_input_f return( req ); } +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 "\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 NULL; +} + /* This one is actually pretty simple... Might get more calls if we can't write the whole request at once. */ static void http_connected( gpointer data, int source, GaimInputCondition cond ) diff --git a/protocols/http_client.h b/protocols/http_client.h index 53c6fcd6..0935b5f6 100644 --- a/protocols/http_client.h +++ b/protocols/http_client.h @@ -52,3 +52,4 @@ struct http_request }; void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ); +void *http_dorequest_url( char *url_string, http_input_function func, gpointer data ); |