lt sync 3253 - fix ssl trackers

This commit is contained in:
Andrew Resch 2009-02-11 15:27:19 +00:00
parent f521795552
commit 7842ad5d3d
3 changed files with 16 additions and 10 deletions

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_XML_PARSE_HPP #define TORRENT_XML_PARSE_HPP
#include <cctype> #include <cctype>
#include <cstring>
namespace libtorrent namespace libtorrent
{ {
@ -49,6 +50,12 @@ namespace libtorrent
xml_parse_error xml_parse_error
}; };
inline bool isspace(char c)
{
const static char* ws = " \t\n\r\f\v";
return std::strchr(ws, c);
}
// callback(int type, char const* name, char const* val) // callback(int type, char const* name, char const* val)
// str2 is only used for attributes. name is element or attribute // str2 is only used for attributes. name is element or attribute
// name and val is attribute value // name and val is attribute value
@ -82,7 +89,7 @@ namespace libtorrent
++p; ++p;
// parse the name of the tag. // parse the name of the tag.
for (start = p; p != end && *p != '>' && !std::isspace(*p); ++p); for (start = p; p != end && *p != '>' && !isspace(*p); ++p);
char* tag_name_end = p; char* tag_name_end = p;
@ -149,11 +156,11 @@ namespace libtorrent
for (char* i = tag_name_end; i < tag_end; ++i) for (char* i = tag_name_end; i < tag_end; ++i)
{ {
// find start of attribute name // find start of attribute name
for (; i != tag_end && std::isspace(*i); ++i); for (; i != tag_end && isspace(*i); ++i);
if (i == tag_end) break; if (i == tag_end) break;
start = i; start = i;
// find end of attribute name // find end of attribute name
for (; i != tag_end && *i != '=' && !std::isspace(*i); ++i); for (; i != tag_end && *i != '=' && !isspace(*i); ++i);
char* name_end = i; char* name_end = i;
// look for equality sign // look for equality sign
@ -169,7 +176,7 @@ namespace libtorrent
} }
++i; ++i;
for (; i != tag_end && std::isspace(*i); ++i); for (; i != tag_end && isspace(*i); ++i);
// check for parse error (values must be quoted) // check for parse error (values must be quoted)
if (i == tag_end || (*i != '\'' && *i != '\"')) if (i == tag_end || (*i != '\'' && *i != '\"'))
{ {

View File

@ -399,8 +399,11 @@ void http_connection::on_read(error_code const& e
TORRENT_ASSERT(m_download_quota >= 0); TORRENT_ASSERT(m_download_quota >= 0);
} }
if (e == asio::error::eof) // when using the asio SSL wrapper, it seems like
// we get the shut_down error instead of EOF
if (e == asio::error::eof || e == asio::error::shut_down)
{ {
error_code ec = asio::error::eof;
TORRENT_ASSERT(bytes_transferred == 0); TORRENT_ASSERT(bytes_transferred == 0);
char const* data = 0; char const* data = 0;
std::size_t size = 0; std::size_t size = 0;
@ -409,7 +412,7 @@ void http_connection::on_read(error_code const& e
data = m_parser.get_body().begin; data = m_parser.get_body().begin;
size = m_parser.get_body().left(); size = m_parser.get_body().left();
} }
callback(e, data, size); callback(ec, data, size);
close(); close();
return; return;
} }

View File

@ -2375,10 +2375,6 @@ namespace libtorrent
} }
#endif #endif
// add the newly connected peer to this torrent's peer list
m_connections.insert(boost::get_pointer(c));
m_ses.m_connections.insert(c);
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
try try
{ {