From 6c61d6ac671ff4911772a6db7fbcc3ec293522fb Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Thu, 25 Aug 2011 09:08:50 +0000 Subject: [PATCH] (trunk libT) #4437 "Multi file webseeds don't work" -- fixed. --- libtransmission/webseed.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libtransmission/webseed.c b/libtransmission/webseed.c index 0cc872d9b..8d7eb055b 100644 --- a/libtransmission/webseed.c +++ b/libtransmission/webseed.c @@ -41,6 +41,7 @@ struct tr_webseed_task struct tr_web_task * web_task; long response_code; int torrent_id; + bool bad_range; }; struct tr_webseed @@ -414,6 +415,8 @@ web_response_func( tr_session * session, /* now wait a while until retrying to establish a connection */ ++w->retry_tickcount; + t->bad_range = response_code == 416; + tr_list_remove_data( &w->tasks, t ); evbuffer_free( t->content ); tr_free( t ); @@ -456,15 +459,18 @@ web_response_func( tr_session * session, } static struct evbuffer * -make_url( tr_webseed * w, const tr_file * file ) +make_url( struct tr_webseed_task * t, const tr_file * file ) { struct evbuffer * buf = evbuffer_new( ); + struct tr_webseed * w = t->webseed; evbuffer_add( buf, w->base_url, w->base_url_len ); - /* if url ends with a '/', add the torrent name */ - if( w->base_url[w->base_url_len - 1] == '/' && file->name ) + if( t->bad_range || ( w->base_url[w->base_url_len - 1] == '/' && file->name ) ) { + if( t->bad_range ) + evbuffer_add( buf, "/", 1 ); tr_http_escape( buf, file->name, strlen(file->name), false ); + } return buf; } @@ -499,7 +505,7 @@ task_request_next_chunk( struct tr_webseed_task * t ) this_pass = MIN( remain, file->length - file_offset ); if( !urls[file_index] ) - urls[file_index] = evbuffer_free_to_str( make_url( t->webseed, file ) ); + urls[file_index] = evbuffer_free_to_str( make_url( t, file ) ); tr_snprintf( range, sizeof range, "%"PRIu64"-%"PRIu64, file_offset, file_offset + this_pass - 1 ); -- 2.40.0