}
else if (!memcmp (torrentPath, "http", 4))
{
- tr_webRun (h, torrentPath, NULL, NULL, onTorrentFileDownloaded, ctor);
+ tr_webRun (h, torrentPath, onTorrentFileDownloaded, ctor);
waitingOnWeb = true;
while (waitingOnWeb)
tr_wait_msec (1000);
fav->contents = NULL;
fav->len = 0;
- tr_webRun (fav->session, url, NULL, NULL, favicon_web_done_cb, fav);
+ tr_webRun (fav->session, url, favicon_web_done_cb, fav);
g_free (url);
}
}
data->host = g_strdup (host);
data->type = 0;
- tr_webRun (session, url, NULL, NULL, favicon_web_done_cb, data);
+ tr_webRun (session, url, favicon_web_done_cb, data);
g_free (url);
}
}
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, NULL, on_announce_done, d);
+ tr_webRun (session, url, on_announce_done, d);
tr_free (url);
}
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, NULL, on_scrape_done, d);
+ tr_webRun (session, url, on_scrape_done, d);
tr_free (url);
}
{
const int port = tr_sessionGetPeerPort (session);
char * url = tr_strdup_printf ("http://portcheck.transmissionbt.com/%d", port);
- tr_webRun (session, url, NULL, NULL, portTested, idle_data);
+ tr_webRun (session, url, portTested, idle_data);
tr_free (url);
return NULL;
}
static const char*
blocklistUpdate (tr_session * session,
- tr_variant * args_in UNUSED,
- tr_variant * args_out UNUSED,
+ tr_variant * args_in UNUSED,
+ tr_variant * args_out UNUSED,
struct tr_rpc_idle_data * idle_data)
{
- tr_webRun (session, session->blocklist_url, NULL, NULL, gotNewBlocklist, idle_data);
+ tr_webRun (session, session->blocklist_url, gotNewBlocklist, idle_data);
return NULL;
}
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, cookies, gotMetadataFromURL, d);
+ tr_webRunWithCookies (session, filename, cookies, gotMetadataFromURL, d);
}
else
{
#include "transmission.h"
#include "log.h"
#include "net.h" /* tr_address */
+#include "torrent.h"
#include "platform.h" /* mutex */
#include "session.h"
#include "trevent.h" /* tr_runInEventThread () */
struct tr_web_task
{
+ int torrentId;
long code;
long timeout_secs;
bool did_connect;
*****
****/
-struct tr_web_task *
-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)
-{
- return tr_webRunWithBuffer (session, url, range, cookies,
- done_func, done_func_user_data,
- NULL);
-}
-
static void tr_webThreadFunc (void * vsession);
-struct tr_web_task *
-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)
+static struct tr_web_task *
+tr_webRunImpl (tr_session * session,
+ int torrentId,
+ const char * url,
+ const char * range,
+ const char * cookies,
+ tr_web_done_func done_func,
+ void * done_func_user_data,
+ struct evbuffer * buffer)
{
struct tr_web_task * task = NULL;
task = tr_new0 (struct tr_web_task, 1);
task->session = session;
+ task->torrentId = torrentId;
task->url = tr_strdup (url);
task->range = tr_strdup (range);
task->cookies = tr_strdup (cookies);
return task;
}
+struct tr_web_task *
+tr_webRunWithCookies (tr_session * session,
+ const char * url,
+ const char * cookies,
+ tr_web_done_func done_func,
+ void * done_func_user_data)
+{
+ return tr_webRunImpl (session, -1, url,
+ NULL, cookies,
+ done_func, done_func_user_data,
+ NULL);
+}
+
+struct tr_web_task *
+tr_webRun (tr_session * session,
+ const char * url,
+ tr_web_done_func done_func,
+ void * done_func_user_data)
+{
+ return tr_webRunWithCookies (session, url, NULL,
+ done_func, done_func_user_data);
+}
+
+
+struct tr_web_task *
+tr_webRunWebseed (tr_torrent * tor,
+ const char * url,
+ const char * range,
+ tr_web_done_func done_func,
+ void * done_func_user_data,
+ struct evbuffer * buffer)
+{
+ return tr_webRunImpl (tor->session, tr_torrentId (tor), url,
+ range, NULL,
+ done_func, done_func_user_data,
+ buffer);
+}
+
/**
* Portability wrapper for select ().
*
struct tr_web_task * 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);
+struct tr_web_task * tr_webRunWithCookies (tr_session * session,
+ const char * url,
+ const char * cookies,
+ tr_web_done_func done_func,
+ void * done_func_user_data);
+
struct evbuffer;
-struct tr_web_task * 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);
+struct tr_web_task * tr_webRunWebseed (tr_torrent * tor,
+ const char * url,
+ const char * range,
+ tr_web_done_func done_func,
+ void * done_func_user_data,
+ struct evbuffer * buffer);
void tr_webGetTaskInfo (struct tr_web_task * task, tr_web_task_info info, void * dst);
tr_snprintf (range, sizeof range, "%"PRIu64"-%"PRIu64,
file_offset, file_offset + this_pass - 1);
- t->web_task = tr_webRunWithBuffer (w->session, urls[file_index],
- range, NULL, web_response_func, t, t->content);
+
+ t->web_task = tr_webRunWebseed (tor, urls[file_index], range,
+ web_response_func, t, t->content);
}
}