diff options
author | tonio <tonio@pkgsrc.org> | 2011-11-18 21:06:19 +0000 |
---|---|---|
committer | tonio <tonio@pkgsrc.org> | 2011-11-18 21:06:19 +0000 |
commit | e43094832c42f5b0685d402c2bc407611b77e84a (patch) | |
tree | 7bf734ac5560a5c846812894d180141b9c4fb8c4 /chat/bitlbee/patches | |
parent | 026c6fe3eead3ac59f7f5a5fa8bcc26f633cda6c (diff) | |
download | pkgsrc-e43094832c42f5b0685d402c2bc407611b77e84a.tar.gz |
Fix problem with msn connect, reported by Frédéric Fauberteau
The patch is obtained using revisions 824 and 825 of the bitlbee repository
Diffstat (limited to 'chat/bitlbee/patches')
-rw-r--r-- | chat/bitlbee/patches/patch-lib_http__client.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/chat/bitlbee/patches/patch-lib_http__client.c b/chat/bitlbee/patches/patch-lib_http__client.c new file mode 100644 index 00000000000..96e0c8ef99d --- /dev/null +++ b/chat/bitlbee/patches/patch-lib_http__client.c @@ -0,0 +1,66 @@ +$NetBSD: patch-lib_http__client.c,v 1.1 2011/11/18 21:06:19 tonio Exp $ + +Fix for MSN login troubles + +--- lib/http_client.c (revision devel,783) ++++ lib/http_client.c (revision devel,825) +@@ -314,5 +314,5 @@ + } + +- 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; +@@ -354,4 +354,5 @@ + url_t *url; + char *s; ++ const char *new_method; + + s = strstr( loc, "\r\n" ); +@@ -369,25 +370,34 @@ + } + +- /* Okay, this isn't fun! We have to rebuild the request... :-( */ +- new_request = g_malloc( req->request_length + strlen( url->file ) ); +- +- /* 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 = strstr( req->request, "\r\n" ); +- if( s == NULL ) ++ /* Find all headers and, if necessary, the POST request contents. ++ Skip the old Host: header though. This crappy code here means ++ anything using this http_client MUST put the Host: header at ++ the top. */ ++ 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 ); + g_free( url ); + goto cleanup; + } + +- strcat( new_request, s ); ++ /* More or less HTTP/1.0 compliant, from my reading of RFC 2616. ++ Always perform a GET request unless we received a 301. 303 was ++ meant for this but it's HTTP/1.1-only and we're specifically ++ speaking HTTP/1.0. */ ++ new_method = req->status_code != 301 || req->request[0] == 'G' ? "GET" : "POST"; ++ ++ /* Okay, this isn't fun! We have to rebuild the request... :-( */ ++ new_request = g_strdup_printf( "%s %s HTTP/1.0\r\nHost: %s%s", ++ new_method, url->file, url->host, s ); ++ + new_host = g_strdup( url->host ); + new_port = url->port; + new_proto = url->proto; ++ ++ /* If we went from POST to GET, truncate the request content. */ ++ if( new_request[0] != req->request[0] && new_request[0] == 'G' && ++ ( s = strstr( new_request, "\r\n\r\n" ) ) ) ++ s[4] = '\0'; + + g_free( url ); |