Ticket #4081: cookies-01.diff
File cookies-01.diff, 9.8 KB (added by jordan, 12 years ago) |
---|
-
libtransmission/rpcimpl.c
1099 1099 { 1100 1100 const int port = tr_sessionGetPeerPort( session ); 1101 1101 char * url = tr_strdup_printf( "http://portcheck.transmissionbt.com/%d", port ); 1102 tr_webRun( session, url, NULL, portTested, idle_data );1102 tr_webRun( session, url, NULL, NULL, portTested, idle_data ); 1103 1103 tr_free( url ); 1104 1104 return NULL; 1105 1105 } … … 1205 1205 tr_benc * args_out UNUSED, 1206 1206 struct tr_rpc_idle_data * idle_data ) 1207 1207 { 1208 tr_webRun( session, session->blocklist_url, NULL, gotNewBlocklist, idle_data );1208 tr_webRun( session, session->blocklist_url, NULL, NULL, gotNewBlocklist, idle_data ); 1209 1209 return NULL; 1210 1210 } 1211 1211 … … 1330 1330 { 1331 1331 int64_t i; 1332 1332 tr_bool boolVal; 1333 tr_benc * l; 1333 1334 const char * str; 1334 tr_benc * l;1335 const char * cookies = NULL; 1335 1336 tr_ctor * ctor = tr_ctorNew( session ); 1336 1337 1337 1338 /* set the optional arguments */ 1338 1339 1340 tr_bencDictFindStr( args_in, "cookies", &cookies ); 1341 1339 1342 if( tr_bencDictFindStr( args_in, TR_PREFS_KEY_DOWNLOAD_DIR, &str ) ) 1340 1343 tr_ctorSetDownloadDir( ctor, TR_FORCE, str ); 1341 1344 … … 1387 1390 struct add_torrent_idle_data * d = tr_new0( struct add_torrent_idle_data, 1 ); 1388 1391 d->data = idle_data; 1389 1392 d->ctor = ctor; 1390 tr_webRun( session, filename, NULL, gotMetadataFromURL, d );1393 tr_webRun( session, filename, NULL, cookies, gotMetadataFromURL, d ); 1391 1394 } 1392 1395 else 1393 1396 { -
libtransmission/webseed.c
290 290 url = make_url( t->webseed, file ); 291 291 tr_snprintf( range, sizeof range, "%"PRIu64"-%"PRIu64, 292 292 file_offset, file_offset + this_pass - 1 ); 293 tr_webRunWithBuffer( t->session, url, range, 293 tr_webRunWithBuffer( t->session, url, range, NULL, 294 294 web_response_func, t, t->content ); 295 295 tr_free( url ); 296 296 } -
libtransmission/torrent-ctor.c
46 46 47 47 struct optional_args optionalArgs[2]; 48 48 49 char * cookies; 49 50 char * incompleteDir; 50 51 51 52 tr_file_index_t * want; -
libtransmission/announcer-http.c
289 289 tr_strlcpy( d->log_name, request->log_name, sizeof( d->log_name ) ); 290 290 291 291 dbgmsg( request->log_name, "Sending announce to libcurl: \"%s\"", url ); 292 tr_webRun( session, url, NULL, on_announce_done, d );292 tr_webRun( session, url, NULL, NULL, on_announce_done, d ); 293 293 tr_free( url ); 294 294 } 295 295 … … 443 443 tr_strlcpy( d->log_name, request->log_name, sizeof( d->log_name ) ); 444 444 445 445 dbgmsg( request->log_name, "Sending scrape to libcurl: \"%s\"", url ); 446 tr_webRun( session, url, NULL, on_scrape_done, d );446 tr_webRun( session, url, NULL, NULL, on_scrape_done, d ); 447 447 tr_free( url ); 448 448 } -
libtransmission/web.c
79 79 struct evbuffer * freebuf; 80 80 char * url; 81 81 char * range; 82 char * cookies; 82 83 tr_session * session; 83 84 tr_web_done_func * done_func; 84 85 void * done_func_user_data; … … 89 90 { 90 91 if( task->freebuf ) 91 92 evbuffer_free( task->freebuf ); 93 tr_free( task->cookies ); 92 94 tr_free( task->range ); 93 95 tr_free( task->url ); 94 96 tr_free( task ); … … 180 182 else if ((( addr = tr_sessionGetPublicAddress( s, TR_AF_INET6, &is_default_value ))) && !is_default_value ) 181 183 curl_easy_setopt( e, CURLOPT_INTERFACE, tr_ntop_non_ts( addr ) ); 182 184 185 if( task->cookies != NULL ) 186 curl_easy_setopt( e, CURLOPT_COOKIE, task->cookies ); 187 183 188 if( task->range ) 184 189 curl_easy_setopt( e, CURLOPT_RANGE, task->range ); 185 190 … … 220 225 tr_webRun( tr_session * session, 221 226 const char * url, 222 227 const char * range, 228 const char * cookies, 223 229 tr_web_done_func done_func, 224 230 void * done_func_user_data ) 225 231 { 226 tr_webRunWithBuffer( session, url, range, 232 tr_webRunWithBuffer( session, url, range, cookies, 227 233 done_func, done_func_user_data, 228 234 NULL ); 229 235 } … … 232 238 tr_webRunWithBuffer( tr_session * session, 233 239 const char * url, 234 240 const char * range, 241 const char * cookies, 235 242 tr_web_done_func done_func, 236 243 void * done_func_user_data, 237 244 struct evbuffer * buffer ) … … 245 252 task->session = session; 246 253 task->url = tr_strdup( url ); 247 254 task->range = tr_strdup( range ); 255 task->cookies = tr_strdup( cookies); 248 256 task->done_func = done_func; 249 257 task->done_func_user_data = done_func_user_data; 250 258 task->response = buffer ? buffer : evbuffer_new( ); -
libtransmission/web.h
55 55 void tr_webRun( tr_session * session, 56 56 const char * url, 57 57 const char * range, 58 const char * cookies, 58 59 tr_web_done_func done_func, 59 60 void * done_func_user_data ); 60 61 … … 63 64 void tr_webRunWithBuffer( tr_session * session, 64 65 const char * url, 65 66 const char * range, 67 const char * cookies, 66 68 tr_web_done_func done_func, 67 69 void * done_func_user_data, 68 70 struct evbuffer * buffer ); -
gtk/favicon.c
111 111 fav->contents = NULL; 112 112 fav->len = 0; 113 113 114 tr_webRun( fav->session, url, NULL, favicon_web_done_cb, fav );114 tr_webRun( fav->session, url, NULL, NULL, favicon_web_done_cb, fav ); 115 115 g_free( url ); 116 116 } 117 117 } … … 167 167 data->host = g_strdup( host ); 168 168 data->type = 0; 169 169 170 tr_webRun( session, url, NULL, favicon_web_done_cb, data );170 tr_webRun( session, url, NULL, NULL, favicon_web_done_cb, data ); 171 171 g_free( url ); 172 172 } 173 173 } -
gtk/tr-core.c
1194 1194 data->core = core; 1195 1195 data->url = g_strdup( url ); 1196 1196 core_inc_busy( data->core ); 1197 tr_webRun( session, url, NULL, on_url_done, data );1197 tr_webRun( session, url, NULL, NULL, on_url_done, data ); 1198 1198 } 1199 1199 } 1200 1200 -
extras/rpc-spec.txt
347 347 348 348 key | value type & description 349 349 ---------------------+------------------------------------------------- 350 "cookies" | string pointer to a string of one or more cookies. 350 351 "download-dir" | string path to download the torrent to 351 352 "filename" | string filename or URL of the .torrent file 352 353 "metainfo" | string base64-encoded .torrent content … … 362 363 Either "filename" OR "metainfo" MUST be included. 363 364 All other arguments are optional. 364 365 366 The format of the "cookies" should be NAME=CONTENTS, where NAME is the 367 cookie name and CONTENTS is what the cookie should contain. 368 Set multiple cookies like this: "name1=content1; name2=content2;" etc. 369 <http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCOOKIE> 370 365 371 Response arguments: on success, a "torrent-added" object in the 366 372 form of one of 3.3's tr_info objects with the 367 373 fields for id, name, and hashString. … … 655 661 | | yes | session-close | new method 656 662 ------+---------+-----------+----------------+------------------------------- 657 663 13 | 2.30 | yes | session-get | new arg "isUTP" to the "peers" list 664 | | yes | torrent-add | new arg "cookies" 658 665 | | NO | torrent-get | removed arg "peersKnown" -
cli/cli.c
269 269 } else if( !memcmp( torrentPath, "magnet:?", 8 ) ) { 270 270 tr_ctorSetMetainfoFromMagnetLink( ctor, torrentPath ); 271 271 } else if( !memcmp( torrentPath, "http", 4 ) ) { 272 tr_webRun( h, torrentPath, NULL, onTorrentFileDownloaded, ctor );272 tr_webRun( h, torrentPath, NULL, NULL, onTorrentFileDownloaded, ctor ); 273 273 waitingOnWeb = TRUE; 274 274 while( waitingOnWeb ) tr_wait_msec( 1000 ); 275 275 } else {