--- Downloads/bitlbee-3.0.3/lib/http_client.c 2011-06-12 13:53:51.000000000 +0200 +++ PRJ/bitlbee/bitlbee-3.0.3/lib/http_client.c 2011-11-12 17:35:44.000000000 +0100 @@ -353,6 +353,7 @@ got_reply: /* A whole URL */ url_t *url; char *s; + char *s2; s = strstr( loc, "\r\n" ); if( s == NULL ) @@ -369,12 +370,15 @@ got_reply: } /* Okay, this isn't fun! We have to rebuild the request... :-( */ - new_request = g_malloc( req->request_length + strlen( url->file ) ); + new_request = g_malloc( req->request_length + strlen( url->file ) + strlen(url->host) ); /* 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 ); + if (strstr(req->request, "POST") == req->request) + sprintf( new_request, "POST %s HTTP/1.0", url->file ); + else + sprintf( new_request, "GET %s HTTP/1.0", url->file ); s = strstr( req->request, "\r\n" ); if( s == NULL ) @@ -384,9 +388,19 @@ got_reply: g_free( url ); goto cleanup; } + new_host = g_strdup( url->host ); + /* Replace Host: header */ + s2 = strstr(s, "\r\nHost:"); + s2 = s2 + 2; + *s2 = 0; // terminate string s temporary strcat( new_request, s ); - new_host = g_strdup( url->host ); + strcat( new_request, "Host: "); + strcat( new_request, new_host); + *s2 = 'H'; // restore string + s = strstr(s2, "\r\n"); // next header + strcat( new_request, s ); + new_port = url->port; new_proto = url->proto;