]> granicus.if.org Git - transmission/commitdiff
(trunk libT) when adding the Host: header by hand, make include the host's port
authorCharles Kerr <charles@transmissionbt.com>
Sat, 23 Jan 2010 07:51:51 +0000 (07:51 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sat, 23 Jan 2010 07:51:51 +0000 (07:51 +0000)
libtransmission/web.c

index c43a149096d78f3e5ca09435a8555e5586cfcefb..18db836750db1f2412f569b3f96f639810400512 100644 (file)
@@ -83,6 +83,7 @@ web_free( tr_web * g )
 
 struct tr_web_task
 {
+    int port;
     unsigned long tag;
     struct curl_slist * slist;
     struct evbuffer * response;
@@ -272,7 +273,7 @@ addTask( void * vtask )
             dbgmsg( "old url: \"%s\" -- new url: \"%s\"", task->url, url );
             evbuffer_free( buf );
 
-            host = tr_strdup_printf( "Host: %s", task->host );
+            host = tr_strdup_printf( "Host: %s:%d", task->host, task->port );
             task->slist = curl_slist_append( NULL, host );
             curl_easy_setopt( e, CURLOPT_HTTPHEADER, task->slist );
             tr_free( host );
@@ -375,12 +376,14 @@ dns_ipv4_done_cb( int err, char type, int count, int ttl, void * addresses, void
 static void
 doDNS( void * vtask )
 {
+    int port = -1;
     char * host = NULL;
     struct tr_web_task * task = vtask;
 
     assert( task->resolved_host == NULL );
 
-    if( !tr_httpParseURL( task->url, -1, &host, NULL, NULL ) ) {
+    if( !tr_httpParseURL( task->url, -1, &host, &port, NULL ) ) {
+        task->port = port;
         task->host = host;
         task->resolved_host = dns_get_cached_host( task, host );
     }