diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-16 00:23:04 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-16 00:23:04 +0100 |
commit | 7885d0f3dc255cd7900ee1d398366636c48bcda1 (patch) | |
tree | f0ce6dfc6fbed4d5664de0bdc6bd220ac34da198 | |
parent | e4e0b3764761c8e204bfdf169d83af950d9e6340 (diff) |
Don't be a dumbass and stop following redirects if there doesn't seem to
be an end.
-rw-r--r-- | lib/http_client.c | 3 | ||||
-rw-r--r-- | lib/http_client.h | 2 |
2 files changed, 4 insertions, 1 deletions
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; diff --git a/lib/http_client.h b/lib/http_client.h index d73894a4..726c97a6 100644 --- a/lib/http_client.h +++ b/lib/http_client.h @@ -60,6 +60,8 @@ struct http_request int body_size; /* The number of bytes in reply_body. */ int finished; /* Set to non-0 if the request was completed successfully. */ + int redir_ttl; /* You can set it to 0 if you don't want + http_client to follow them. */ http_input_function func; gpointer data; |