(trunk) #4081 "Add 'cookieString' argument 'torrent-add' method in RPC" -- done.
This commit is contained in:
parent
15e2e7d491
commit
fee784f1d8
|
@ -269,7 +269,7 @@ main( int argc, char ** argv )
|
|||
} else if( !memcmp( torrentPath, "magnet:?", 8 ) ) {
|
||||
tr_ctorSetMetainfoFromMagnetLink( ctor, torrentPath );
|
||||
} else if( !memcmp( torrentPath, "http", 4 ) ) {
|
||||
tr_webRun( h, torrentPath, NULL, onTorrentFileDownloaded, ctor );
|
||||
tr_webRun( h, torrentPath, NULL, NULL, onTorrentFileDownloaded, ctor );
|
||||
waitingOnWeb = TRUE;
|
||||
while( waitingOnWeb ) tr_wait_msec( 1000 );
|
||||
} else {
|
||||
|
|
|
@ -347,6 +347,7 @@
|
|||
|
||||
key | value type & description
|
||||
---------------------+-------------------------------------------------
|
||||
"cookies" | string pointer to a string of one or more cookies.
|
||||
"download-dir" | string path to download the torrent to
|
||||
"filename" | string filename or URL of the .torrent file
|
||||
"metainfo" | string base64-encoded .torrent content
|
||||
|
@ -362,6 +363,11 @@
|
|||
Either "filename" OR "metainfo" MUST be included.
|
||||
All other arguments are optional.
|
||||
|
||||
The format of the "cookies" should be NAME=CONTENTS, where NAME is the
|
||||
cookie name and CONTENTS is what the cookie should contain.
|
||||
Set multiple cookies like this: "name1=content1; name2=content2;" etc.
|
||||
<http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCOOKIE>
|
||||
|
||||
Response arguments: on success, a "torrent-added" object in the
|
||||
form of one of 3.3's tr_info objects with the
|
||||
fields for id, name, and hashString.
|
||||
|
@ -655,4 +661,5 @@
|
|||
| | yes | session-close | new method
|
||||
------+---------+-----------+----------------+-------------------------------
|
||||
13 | 2.30 | yes | session-get | new arg "isUTP" to the "peers" list
|
||||
| | yes | torrent-add | new arg "cookies"
|
||||
| | NO | torrent-get | removed arg "peersKnown"
|
||||
|
|
|
@ -111,7 +111,7 @@ favicon_web_done_idle_cb( gpointer vfav )
|
|||
fav->contents = NULL;
|
||||
fav->len = 0;
|
||||
|
||||
tr_webRun( fav->session, url, NULL, favicon_web_done_cb, fav );
|
||||
tr_webRun( fav->session, url, NULL, NULL, favicon_web_done_cb, fav );
|
||||
g_free( url );
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ gtr_get_favicon( tr_session * session,
|
|||
data->host = g_strdup( host );
|
||||
data->type = 0;
|
||||
|
||||
tr_webRun( session, url, NULL, favicon_web_done_cb, data );
|
||||
tr_webRun( session, url, NULL, NULL, favicon_web_done_cb, data );
|
||||
g_free( url );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1194,7 +1194,7 @@ gtr_core_add_from_url( TrCore * core, const char * url )
|
|||
data->core = core;
|
||||
data->url = g_strdup( url );
|
||||
core_inc_busy( data->core );
|
||||
tr_webRun( session, url, NULL, on_url_done, data );
|
||||
tr_webRun( session, url, NULL, NULL, on_url_done, data );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ tr_tracker_http_announce( tr_session * session,
|
|||
tr_strlcpy( d->log_name, request->log_name, sizeof( d->log_name ) );
|
||||
|
||||
dbgmsg( request->log_name, "Sending announce to libcurl: \"%s\"", url );
|
||||
tr_webRun( session, url, NULL, on_announce_done, d );
|
||||
tr_webRun( session, url, NULL, NULL, on_announce_done, d );
|
||||
tr_free( url );
|
||||
}
|
||||
|
||||
|
@ -443,6 +443,6 @@ tr_tracker_http_scrape( tr_session * session,
|
|||
tr_strlcpy( d->log_name, request->log_name, sizeof( d->log_name ) );
|
||||
|
||||
dbgmsg( request->log_name, "Sending scrape to libcurl: \"%s\"", url );
|
||||
tr_webRun( session, url, NULL, on_scrape_done, d );
|
||||
tr_webRun( session, url, NULL, NULL, on_scrape_done, d );
|
||||
tr_free( url );
|
||||
}
|
||||
|
|
|
@ -1099,7 +1099,7 @@ portTest( tr_session * session,
|
|||
{
|
||||
const int port = tr_sessionGetPeerPort( session );
|
||||
char * url = tr_strdup_printf( "http://portcheck.transmissionbt.com/%d", port );
|
||||
tr_webRun( session, url, NULL, portTested, idle_data );
|
||||
tr_webRun( session, url, NULL, NULL, portTested, idle_data );
|
||||
tr_free( url );
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1205,7 +1205,7 @@ blocklistUpdate( tr_session * session,
|
|||
tr_benc * args_out UNUSED,
|
||||
struct tr_rpc_idle_data * idle_data )
|
||||
{
|
||||
tr_webRun( session, session->blocklist_url, NULL, gotNewBlocklist, idle_data );
|
||||
tr_webRun( session, session->blocklist_url, NULL, NULL, gotNewBlocklist, idle_data );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1330,12 +1330,15 @@ torrentAdd( tr_session * session,
|
|||
{
|
||||
int64_t i;
|
||||
tr_bool boolVal;
|
||||
const char * str;
|
||||
tr_benc * l;
|
||||
const char * str;
|
||||
const char * cookies = NULL;
|
||||
tr_ctor * ctor = tr_ctorNew( session );
|
||||
|
||||
/* set the optional arguments */
|
||||
|
||||
tr_bencDictFindStr( args_in, "cookies", &cookies );
|
||||
|
||||
if( tr_bencDictFindStr( args_in, TR_PREFS_KEY_DOWNLOAD_DIR, &str ) )
|
||||
tr_ctorSetDownloadDir( ctor, TR_FORCE, str );
|
||||
|
||||
|
@ -1387,7 +1390,7 @@ torrentAdd( tr_session * session,
|
|||
struct add_torrent_idle_data * d = tr_new0( struct add_torrent_idle_data, 1 );
|
||||
d->data = idle_data;
|
||||
d->ctor = ctor;
|
||||
tr_webRun( session, filename, NULL, gotMetadataFromURL, d );
|
||||
tr_webRun( session, filename, NULL, cookies, gotMetadataFromURL, d );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -46,6 +46,7 @@ struct tr_ctor
|
|||
|
||||
struct optional_args optionalArgs[2];
|
||||
|
||||
char * cookies;
|
||||
char * incompleteDir;
|
||||
|
||||
tr_file_index_t * want;
|
||||
|
|
|
@ -79,6 +79,7 @@ struct tr_web_task
|
|||
struct evbuffer * freebuf;
|
||||
char * url;
|
||||
char * range;
|
||||
char * cookies;
|
||||
tr_session * session;
|
||||
tr_web_done_func * done_func;
|
||||
void * done_func_user_data;
|
||||
|
@ -89,6 +90,7 @@ task_free( struct tr_web_task * task )
|
|||
{
|
||||
if( task->freebuf )
|
||||
evbuffer_free( task->freebuf );
|
||||
tr_free( task->cookies );
|
||||
tr_free( task->range );
|
||||
tr_free( task->url );
|
||||
tr_free( task );
|
||||
|
@ -180,6 +182,9 @@ createEasy( tr_session * s, struct tr_web_task * task )
|
|||
else if ((( addr = tr_sessionGetPublicAddress( s, TR_AF_INET6, &is_default_value ))) && !is_default_value )
|
||||
curl_easy_setopt( e, CURLOPT_INTERFACE, tr_ntop_non_ts( addr ) );
|
||||
|
||||
if( task->cookies != NULL )
|
||||
curl_easy_setopt( e, CURLOPT_COOKIE, task->cookies );
|
||||
|
||||
if( task->range )
|
||||
curl_easy_setopt( e, CURLOPT_RANGE, task->range );
|
||||
|
||||
|
@ -220,10 +225,11 @@ void
|
|||
tr_webRun( tr_session * session,
|
||||
const char * url,
|
||||
const char * range,
|
||||
const char * cookies,
|
||||
tr_web_done_func done_func,
|
||||
void * done_func_user_data )
|
||||
{
|
||||
tr_webRunWithBuffer( session, url, range,
|
||||
tr_webRunWithBuffer( session, url, range, cookies,
|
||||
done_func, done_func_user_data,
|
||||
NULL );
|
||||
}
|
||||
|
@ -232,6 +238,7 @@ void
|
|||
tr_webRunWithBuffer( tr_session * session,
|
||||
const char * url,
|
||||
const char * range,
|
||||
const char * cookies,
|
||||
tr_web_done_func done_func,
|
||||
void * done_func_user_data,
|
||||
struct evbuffer * buffer )
|
||||
|
@ -245,6 +252,7 @@ tr_webRunWithBuffer( tr_session * session,
|
|||
task->session = session;
|
||||
task->url = tr_strdup( url );
|
||||
task->range = tr_strdup( range );
|
||||
task->cookies = tr_strdup( cookies);
|
||||
task->done_func = done_func;
|
||||
task->done_func_user_data = done_func_user_data;
|
||||
task->response = buffer ? buffer : evbuffer_new( );
|
||||
|
|
|
@ -55,6 +55,7 @@ const char * tr_webGetResponseStr( long response_code );
|
|||
void tr_webRun( tr_session * session,
|
||||
const char * url,
|
||||
const char * range,
|
||||
const char * cookies,
|
||||
tr_web_done_func done_func,
|
||||
void * done_func_user_data );
|
||||
|
||||
|
@ -63,6 +64,7 @@ struct evbuffer;
|
|||
void tr_webRunWithBuffer( tr_session * session,
|
||||
const char * url,
|
||||
const char * range,
|
||||
const char * cookies,
|
||||
tr_web_done_func done_func,
|
||||
void * done_func_user_data,
|
||||
struct evbuffer * buffer );
|
||||
|
|
|
@ -290,7 +290,7 @@ task_request_next_chunk( struct tr_webseed_task * t )
|
|||
url = make_url( t->webseed, file );
|
||||
tr_snprintf( range, sizeof range, "%"PRIu64"-%"PRIu64,
|
||||
file_offset, file_offset + this_pass - 1 );
|
||||
tr_webRunWithBuffer( t->session, url, range,
|
||||
tr_webRunWithBuffer( t->session, url, range, NULL,
|
||||
web_response_func, t, t->content );
|
||||
tr_free( url );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue