* 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
+1
View File
@@ -79,6 +79,7 @@ Control::initialize() {
m_core->get_poll_manager()->signal_interrupted().connect(sigc::mem_fun(*m_inputStdin, &input::InputEvent::event_read));
m_core->get_poll_manager()->signal_interrupted().connect(sigc::ptr_fun(display::Canvas::do_update));
m_core->get_poll_manager()->get_http_stack()->set_user_agent(std::string(PACKAGE "/" VERSION "/") + torrent::get_version());
m_core->initialize_second();
+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;
};
}
+7 -1
View File
@@ -67,6 +67,8 @@ WindowFileList::redraw() {
m_canvas->print(55, pos, "Size");
m_canvas->print(63, pos, "Pri");
m_canvas->print(68, pos, "Cmpl");
m_canvas->print(74, pos, "Encoding");
m_canvas->print(84, pos, "Chunks");
++pos;
@@ -108,7 +110,7 @@ WindowFileList::redraw() {
break;
};
m_canvas->print(0, pos, "%c %s %6.1f %s %3d %s",
m_canvas->print(0, pos, "%c %s %6.1f %s %3d %9s",
range.first == *m_focus ? '*' : ' ',
path.c_str(),
(double)e.get_size() / (double)(1 << 20),
@@ -116,6 +118,10 @@ WindowFileList::redraw() {
done_percentage(e),
e.path_list()->encoding().c_str());
m_canvas->print(84, pos, "%i - %i",
e.get_chunk_begin(),
e.get_chunk_end());
++range.first;
++pos;
}