From 2be24ec9a83521e01ec0904ae946c88941386842 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 22 Jan 2010 07:27:19 +0000 Subject: [PATCH] (trunk libT) #2783 "starting with r9992, IP blocklist is empty" -- when replacing a URL's hostname with an IP address before passing the URL to curl, manually set the Host: header to the original hostname. (Xref: #2781) --- libtransmission/web.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libtransmission/web.c b/libtransmission/web.c index bc7029caa..c43a14909 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -84,6 +84,7 @@ web_free( tr_web * g ) struct tr_web_task { unsigned long tag; + struct curl_slist * slist; struct evbuffer * response; char * url; char * host; @@ -100,6 +101,8 @@ struct tr_web_task static void task_free( struct tr_web_task * task ) { + if( task->slist != NULL ) + curl_slist_free_all( task->slist ); evtimer_del( &task->timer_event ); evbuffer_free( task->response ); tr_free( task->host ); @@ -258,6 +261,7 @@ addTask( void * vtask ) * so that curl's DNS won't block */ if( task->resolved_host != NULL ) { + char * host; struct evbuffer * buf = evbuffer_new( ); char * pch = strstr( task->url, task->host ); char * tail = pch + strlen( task->host ); @@ -267,6 +271,11 @@ addTask( void * vtask ) url = tr_strndup( EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) ); dbgmsg( "old url: \"%s\" -- new url: \"%s\"", task->url, url ); evbuffer_free( buf ); + + host = tr_strdup_printf( "Host: %s", task->host ); + task->slist = curl_slist_append( NULL, host ); + curl_easy_setopt( e, CURLOPT_HTTPHEADER, task->slist ); + tr_free( host ); } dbgmsg( "adding task #%lu [%s]", task->tag, url ? url : task->url );