56
56
UPnPRouterPrivate(const QString & server,const KUrl & location,bool verbose,UPnPRouter* parent);
57
57
~UPnPRouterPrivate();
59
HTTPRequest* sendSoapQuery(const QString& query, const QString& soapact, const KUrl& controlurl, bool at_exit = false);
59
HTTPRequest* sendSoapQuery(const QString& query, const QString& soapact, const QString& controlurl, bool at_exit = false);
60
60
void forward(const UPnPService* srv,const net::Port & port);
61
61
void undoForward(const UPnPService* srv,const net::Port & port,bt::WaitJob* waitjob);
62
62
void httpRequestDone(HTTPRequest* r,bool erase_fwd);
396
HTTPRequest* UPnPRouter::UPnPRouterPrivate::sendSoapQuery(const QString & query,const QString & soapact,const KUrl & controlurl,bool at_exit)
396
HTTPRequest* UPnPRouter::UPnPRouterPrivate::sendSoapQuery(const QString & query,const QString & soapact,const QString & controlurl,bool at_exit)
398
398
// if port is not set, 0 will be returned
399
399
// thanks to Diego R. Brogna for spotting this bug
400
400
if (location.port()<=0)
401
401
location.setPort(80);
403
QString http_hdr = QString(
404
"POST %1 HTTP/1.1\r\n"
407
"Content-length: $CONTENT_LENGTH\r\n"
408
"Content-Type: text/xml\r\n"
409
"SOAPAction: \"%4\"\r\n"
410
"\r\n").arg(controlurl.encodedPathAndQuery()).arg(location.host()).arg(location.port()).arg(soapact).arg(bt::GetVersionString());
412
QString host = controlurl.hasHost() ? controlurl.host() : location.host();
413
bt::Uint16 port = controlurl.hasHost() ? controlurl.port(80) : location.port(80);
403
QUrl ctrlurl(controlurl);
404
QString host = !ctrlurl.host().isEmpty() ? ctrlurl.host() : location.host();
405
bt::Uint16 port = ctrlurl.port() != -1 ? ctrlurl.port() : location.port(80);
408
QTextStream out(&http_hdr);
409
QByteArray encoded_query = ctrlurl.encodedQuery();
410
if (encoded_query.isEmpty())
411
out << "POST " << ctrlurl.encodedPath() << " HTTP/1.1\r\n";
413
out << "POST " << ctrlurl.encodedPath() << "?" << encoded_query << " HTTP/1.1\r\n";
414
out << "Host: " << host << ":" << port << "\r\n";
415
out << "User-Agent: " << bt::GetVersionString() << "\r\n";
416
out << "Content-length: $CONTENT_LENGTH\r\n";
417
out << "Content-Type: text/xml\r\n";
418
out << "SOAPAction: \"" << soapact << "\"\r\n\r\n";
415
420
HTTPRequest* r = new HTTPRequest(http_hdr,query,host,port,verbose);