~ubuntu-branches/ubuntu/wily/libktorrent/wily

« back to all changes in this revision

Viewing changes to src/upnp/upnprouter.cpp

  • Committer: Package Import Robot
  • Author(s): Modestas Vainius
  • Date: 2011-12-06 00:56:03 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20111206005603-1jev0x68bsnq56ba
Tags: 1.1.3-1
* New upstream release.
* Bump debhelper compat level to 9 and require debhelper 8.9.0 in order to
  gain support for transparent dpkg-buildflags handling in dh/dh_auto_*.
* Update symbol file (for 1.1.2/ia64, 1.1.2/sparc), fixes FTBFSes.
* Update symbol file for 1.1.3/amd64, source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
                UPnPRouterPrivate(const QString & server,const KUrl & location,bool verbose,UPnPRouter* parent); 
57
57
                ~UPnPRouterPrivate();
58
58
                
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);
393
393
                }
394
394
        }
395
395
 
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)
397
397
        {
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);
402
402
                
403
 
                QString http_hdr = QString(
404
 
                                "POST %1 HTTP/1.1\r\n"
405
 
                                "Host: %2:%3\r\n"
406
 
                                "User-Agent: %5\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());
411
 
                                
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);
 
406
                
 
407
                QString http_hdr;
 
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";
 
412
                else
 
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";
414
419
                
415
420
                HTTPRequest* r = new HTTPRequest(http_hdr,query,host,port,verbose);
416
421
                if (!at_exit)
550
555
}
551
556
 
552
557
#include "upnprouter.moc"
 
558
 
 
559
 
 
560
 
 
561
 
 
562
 
 
563