*** empty log message ***
This commit is contained in:
parent
a997a43d30
commit
1fbb33f6d2
|
@ -62,6 +62,8 @@ namespace libtorrent
|
|||
struct request_callback;
|
||||
class tracker_manager;
|
||||
|
||||
address parse_url(std::string const& url);
|
||||
|
||||
// encodes a string using the base64 scheme
|
||||
std::string base64encode(const std::string& s);
|
||||
|
||||
|
|
|
@ -558,13 +558,16 @@ namespace libtorrent { namespace detail
|
|||
++i)
|
||||
{
|
||||
connection_map::iterator p = m_connections.find(*i);
|
||||
if (m_alerts.should_post(alert::debug))
|
||||
if (p != m_connections.end())
|
||||
{
|
||||
m_alerts.post_alert(
|
||||
peer_error_alert(
|
||||
p->first->sender()
|
||||
, p->second->id()
|
||||
, "connection closed"));
|
||||
if (m_alerts.should_post(alert::debug))
|
||||
{
|
||||
m_alerts.post_alert(
|
||||
peer_error_alert(
|
||||
p->first->sender()
|
||||
, p->second->id()
|
||||
, "connection closed"));
|
||||
}
|
||||
}
|
||||
|
||||
m_selector.remove(*i);
|
||||
|
|
|
@ -369,11 +369,11 @@ namespace libtorrent
|
|||
|
||||
if (m_files.size() == 1)
|
||||
{
|
||||
info["name"] = m_files.front().path.string();
|
||||
info["name"] = m_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
info["name"] = m_files.front().path.root_name();
|
||||
info["name"] = m_name;
|
||||
}
|
||||
|
||||
if (m_files.size() > 1)
|
||||
|
|
|
@ -74,6 +74,51 @@ namespace
|
|||
namespace libtorrent
|
||||
{
|
||||
|
||||
address parse_url(std::string const& url)
|
||||
{
|
||||
std::string hostname; // hostname only
|
||||
int port = 80;
|
||||
|
||||
// PARSE URL
|
||||
std::string::const_iterator start = url.begin();
|
||||
std::string::const_iterator end
|
||||
= std::find(url.begin(), url.end(), ':');
|
||||
|
||||
if (end == url.end()) throw std::runtime_error("invalid url");
|
||||
++end;
|
||||
if (end == url.end()) throw std::runtime_error("invalid url");
|
||||
if (*end != '/') throw std::runtime_error("invalid url");
|
||||
++end;
|
||||
if (end == url.end()) throw std::runtime_error("invalid url");
|
||||
if (*end != '/') throw std::runtime_error("invalid url");
|
||||
++end;
|
||||
start = end;
|
||||
|
||||
end = std::find(start, url.end(), '/');
|
||||
std::string::const_iterator port_pos
|
||||
= std::find(start, url.end(), ':');
|
||||
|
||||
if (port_pos < end)
|
||||
{
|
||||
hostname.assign(start, port_pos);
|
||||
++port_pos;
|
||||
try
|
||||
{
|
||||
port = boost::lexical_cast<int>(std::string(port_pos, end));
|
||||
}
|
||||
catch(boost::bad_lexical_cast&)
|
||||
{
|
||||
throw std::runtime_error("invalid url: \"" + url + "\"");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hostname.assign(start, end);
|
||||
}
|
||||
|
||||
return address(hostname.c_str(), port);
|
||||
}
|
||||
|
||||
// returns -1 if gzip header is invalid or the header size in bytes
|
||||
int gzip_header(const char* buf, int size)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue