From dff732d93799db858a5728abbf31d2e6274b8425 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 12 Nov 2011 23:49:52 +0800 Subject: Undoing old workaround for MSN troubles and added more proper fix. The http_client module needs some refactoring though. Will do that later.. This should hopefully fix bug #850. --- lib/http_client.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/http_client.c') diff --git a/lib/http_client.c b/lib/http_client.c index 8b045414..f535f13f 100644 --- a/lib/http_client.c +++ b/lib/http_client.c @@ -313,7 +313,7 @@ got_reply: req->status_code = -1; } - if( ( req->status_code == 301 || req->status_code == 302 ) && req->redir_ttl-- > 0 ) + if( ( req->status_code >= 301 && req->status_code <= 303 ) && req->redir_ttl-- > 0 ) { char *loc, *new_request, *new_host; int error = 0, new_port, new_proto; @@ -374,10 +374,13 @@ got_reply: /* So, now I just allocated enough memory, so I'm going to use strcat(), whether you like it or not. :-) */ - sprintf( new_request, "GET %s HTTP/1.0", url->file ); + *s = 0; + sprintf( new_request, "%s %s HTTP/1.0\r\nHost: %s", + req->status_code == 303 || req->request[0] == 'G' ? "GET" : "POST", url->file, url->host ); + *s = ' '; - s = strstr( req->request, "\r\n" ); - if( s == NULL ) + if( !( ( s = strstr( req->request, "\r\nHost: " ) ) && + ( s = strstr( s + strlen( "\r\nHost: " ), "\r\n" ) ) ) ) { req->status_string = g_strdup( "Error while rebuilding request string" ); g_free( new_request ); -- cgit v1.2.3