From 7885d0f3dc255cd7900ee1d398366636c48bcda1 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 16 Jul 2010 00:23:04 +0100 Subject: Don't be a dumbass and stop following redirects if there doesn't seem to be an end. --- lib/http_client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/http_client.c') diff --git a/lib/http_client.c b/lib/http_client.c index aae5645b..dd5f5563 100644 --- a/lib/http_client.c +++ b/lib/http_client.c @@ -66,6 +66,7 @@ void *http_dorequest( char *host, int port, int ssl, char *request, http_input_f req->data = data; req->request = g_strdup( request ); req->request_length = strlen( request ); + req->redir_ttl = 3; return( req ); } @@ -310,7 +311,7 @@ got_reply: req->status_code = -1; } - if( req->status_code == 301 || req->status_code == 302 ) + if( ( req->status_code == 301 || req->status_code == 302 ) && req->redir_ttl-- > 0 ) { char *loc, *new_request, *new_host; int error = 0, new_port, new_proto; -- cgit v1.2.3 From 516a9c69222bed3d6fee7aefb439b461e4173da0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 17 Jul 2010 00:11:37 +0100 Subject: No idea why http_dorequest() ever returned void*. Don't hide the type, it's not a secret (the pointer is shared with a type later anyway). --- lib/http_client.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/http_client.c') diff --git a/lib/http_client.c b/lib/http_client.c index dd5f5563..529be578 100644 --- a/lib/http_client.c +++ b/lib/http_client.c @@ -34,9 +34,10 @@ 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_free( struct http_request *req ); -void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ) +struct http_request *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ) { struct http_request *req; int error = 0; @@ -71,7 +72,7 @@ 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 ) +struct http_request *http_dorequest_url( char *url_string, http_input_function func, gpointer data ) { url_t *url = g_new0( url_t, 1 ); char *request; @@ -445,7 +446,7 @@ cleanup: return FALSE; } -void http_free( struct http_request *req ) +static void http_free( struct http_request *req ) { g_free( req->request ); g_free( req->reply_headers ); -- cgit v1.2.3