* Moved http get's user agent stuff to the client. It now uses

"rtorrent/CLIENT_VERSION/LIBRARY_VERSION".

* Using libcurl's timeout, set to 60 seconds, rather than in
TrackerHttp. This should make libcurl try different IP's.

* Minor cleanup of how file priorities are updated.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@594 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-11-08 21:14:32 +00:00
parent b28621f839
commit 3db8179274
6 changed files with 30 additions and 7 deletions
+10 -4
View File
@@ -81,12 +81,13 @@ CurlGet::start() {
m_handle = curl_easy_init();
curl_easy_setopt(m_handle, CURLOPT_URL, m_url.c_str());
curl_easy_setopt(m_handle, CURLOPT_USERAGENT, m_userAgent.c_str());
curl_easy_setopt(m_handle, CURLOPT_WRITEFUNCTION, &curl_get_receive_write);
curl_easy_setopt(m_handle, CURLOPT_WRITEDATA, this);
curl_easy_setopt(m_handle, CURLOPT_URL, m_url.c_str());
curl_easy_setopt(m_handle, CURLOPT_WRITEFUNCTION, &curl_get_receive_write);
curl_easy_setopt(m_handle, CURLOPT_WRITEDATA, this);
curl_easy_setopt(m_handle, CURLOPT_TIMEOUT, 60);
curl_easy_setopt(m_handle, CURLOPT_FORBID_REUSE, 1);
curl_easy_setopt(m_handle, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(m_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(m_handle, CURLOPT_MAXREDIRS, 5);
@@ -122,6 +123,11 @@ CurlGet::get_size_total() {
return d;
}
void
CurlGet::set_user_agent(const char* s) {
curl_easy_setopt(m_handle, CURLOPT_USERAGENT, s);
}
void
CurlGet::perform(CURLMsg* msg) {
if (msg->msg != CURLMSG_DONE)
+4 -2
View File
@@ -61,13 +61,15 @@ class CurlGet : public torrent::Http {
void start();
void close();
bool is_busy() { return m_handle; }
bool is_busy() { return m_handle; }
double get_size_done();
double get_size_total();
void set_user_agent(const char* s);
protected:
CURL* handle() { return m_handle; }
CURL* handle() { return m_handle; }
void perform(CURLMsg* msg);
+2
View File
@@ -103,6 +103,8 @@ CurlStack::fdset(fd_set* readfds, fd_set* writefds, fd_set* exceptfds) {
void
CurlStack::add_get(CurlGet* get) {
get->set_user_agent(m_userAgent.c_str());
CURLMcode code;
if ((code = curl_multi_add_handle((CURLM*)m_handle, get->handle())) > 0)
+6
View File
@@ -38,6 +38,7 @@
#define RTORRENT_CORE_CURL_STACK_H
#include <list>
#include <string>
#include <sigc++/slot.h>
namespace core {
@@ -64,6 +65,9 @@ class CurlStack {
SlotFactory get_http_factory();
const std::string& user_agent() const { return m_userAgent; }
void set_user_agent(const std::string& s) { m_userAgent = s; }
static void global_init();
static void global_cleanup();
@@ -79,6 +83,8 @@ class CurlStack {
int m_size;
CurlGetList m_getList;
std::string m_userAgent;
};
}