Fixed UPnP bug where the port and host would be re-used from the xml url when connecting to the control url

This commit is contained in:
Arvid Norberg 2008-10-14 07:19:46 +00:00
parent f0f285ae63
commit 9a5e261c64
2 changed files with 20 additions and 1 deletions

View File

@ -200,6 +200,9 @@ private:
std::vector<mapping_t> mapping;
// this is the hostname, port and path
// component of the url or the control_url
// if it has been found
std::string hostname;
int port;
std::string path;

View File

@ -560,7 +560,7 @@ void upnp::post(upnp::rootdevice const& d, std::string const& soap
std::stringstream header;
header << "POST " << d.control_url << " HTTP/1.1\r\n"
header << "POST " << d.path << " HTTP/1.1\r\n"
"Host: " << d.hostname << ":" << d.port << "\r\n"
"Content-Type: text/xml; charset=\"utf-8\"\r\n"
"Content-Length: " << soap.size() << "\r\n"
@ -876,6 +876,22 @@ void upnp::on_upnp_xml(error_code const& e
d.control_url = s.control_url;
std::string protocol;
std::string auth;
char const* error;
boost::tie(protocol, auth, d.hostname, d.port, d.path, error)
= parse_url_components(d.control_url);
if (error)
{
#ifdef TORRENT_UPNP_LOGGING
m_log << time_now_string()
<< " *** Failed to parse URL '" << d.control_url << "': " << error << std::endl;
#endif
d.disabled = true;
return;
}
if (num_mappings() > 0) update_map(d, 0);
}