diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index 54e832c8a..5913e70d0 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -200,6 +200,9 @@ private: std::vector 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; diff --git a/src/upnp.cpp b/src/upnp.cpp index 37066bf40..ce5d54421 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -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); }