aboutsummaryrefslogtreecommitdiffstats
path: root/lib/http_client.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2013-06-16 01:14:11 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2013-06-16 01:14:11 +0100
commitdd7b931d0fe950c5a6646c72565739fd8835c136 (patch)
tree1abf729af949c7720af6d70559cfe259ad7a4d8d /lib/http_client.c
parent777461be5e14d3aab9a51f19b5d2621309141a9d (diff)
Use HTTP/1.1 by default in the Twitter module, and stick to the initially
used protocol version when internally handling redirects.
Diffstat (limited to 'lib/http_client.c')
-rw-r--r--lib/http_client.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/http_client.c b/lib/http_client.c
index a5ec5867..e78cb59d 100644
--- a/lib/http_client.c
+++ b/lib/http_client.c
@@ -535,7 +535,7 @@ static gboolean http_handle_headers( struct http_request *req )
{
/* A whole URL */
url_t *url;
- char *s;
+ char *s, *version, *headers;
const char *new_method;
s = strstr( loc, "\r\n" );
@@ -563,6 +563,7 @@ static gboolean http_handle_headers( struct http_request *req )
g_free( url );
return TRUE;
}
+ headers = 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
@@ -582,9 +583,19 @@ static gboolean http_handle_headers( struct http_request *req )
/* 301 de-facto should stay POST, 307 specifally RFC 2616#10.3.8 */
new_method = "POST";
+ if( ( version = strstr( req->request, " HTTP/" ) ) &&
+ ( s = strstr( version, "\r\n" ) ) )
+ {
+ version ++;
+ version = g_strndup( version, s - version );
+ }
+ else
+ version = g_strdup( "HTTP/1.0" );
+
/* Okay, this isn't fun! We have to rebuild the request... :-( */
- new_request = g_strdup_printf( "%s %s HTTP/1.1\r\nHost: %s%s",
- new_method, url->file, url->host, s );
+ new_request = g_strdup_printf( "%s %s %s\r\nHost: %s%s",
+ new_method, url->file, version,
+ url->host, headers );
new_host = g_strdup( url->host );
new_port = url->port;
@@ -596,6 +607,7 @@ static gboolean http_handle_headers( struct http_request *req )
s[4] = '\0';
g_free( url );
+ g_free( version );
}
if( req->ssl )