Changeset 1335 in ntrip
- Timestamp:
- Dec 26, 2008, 10:55:52 AM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncnetrequest.cpp
r1305 r1335 22 22 using namespace std; 23 23 24 #define AGENTVERSION "1.7"25 26 24 // Constructor 27 25 //////////////////////////////////////////////////////////////////////////// … … 40 38 // Network Request 41 39 //////////////////////////////////////////////////////////////////////////// 42 t_irc bncNetRequest::request(const QUrl& mountPoint, const QByteArray& ggaStr) {40 t_irc bncNetRequest::request(const QUrl& url) { 43 41 44 42 // Network Access Manager … … 51 49 } 52 50 53 // Proxy54 // -----55 QSettings settings;56 QString proxyHost = settings.value("proxyHost").toString();57 if (proxyHost.isEmpty()) {58 QNetworkProxy proxy(QNetworkProxy::NoProxy);59 _manager->setProxy(proxy);60 }61 else {62 QNetworkProxy proxy(QNetworkProxy::Socks5Proxy);63 proxy.setHostName(proxyHost);64 proxy.setPort(settings.value("proxyPort").toInt());65 _manager->setProxy(proxy);66 }67 68 connect(_manager, SIGNAL(finished(QNetworkReply*)),69 this, SLOT(slotReplyFinished(QNetworkReply*)));70 71 51 // Network Request 72 52 // --------------- 73 /// QNetworkRequest request; 74 /// request.setUrl(mountPoint); 75 /// request.setRawHeader("User-Agent", "NTRIP BNC/" AGENTVERSION); 76 /// request.setRawHeader("Host", mountPoint.host().toAscii()); 77 /// 78 /// QString uName = QUrl::fromPercentEncoding(mountPoint.userName().toAscii()); 79 /// QString passW = QUrl::fromPercentEncoding(mountPoint.password().toAscii()); 80 /// if (!uName.isEmpty() || !passW.isEmpty()) { 81 /// QByteArray userAndPwd = "Basic " + (uName.toAscii() + ":" + 82 /// passW.toAscii()).toBase64(); 83 /// request.setRawHeader("Authorization", userAndPwd); 84 /// } 85 /// 86 /// if (!ggaStr.isEmpty()) { 87 /// request.setRawHeader("", ggaStr); 88 /// } 53 QNetworkRequest request; 54 request.setUrl(url); 55 request.setRawHeader("Host" , url.host().toAscii()); 56 request.setRawHeader("Ntrip-Version", "NTRIP/2.0"); 57 request.setRawHeader("User-Agent" , "NTRIP BNC/1.7"); 58 if (!url.userName().isEmpty()) { 59 request.setRawHeader("Authorization", "Basic " + 60 (url.userName() + ":" + url.password()).toAscii().toBase64()); 61 } 62 request.setRawHeader("Connection" , "close"); 89 63 90 QHttpRequestHeader header("GET", "/CBRU0", 1, 1);64 _reply = _manager->get(request); 91 65 92 header.addValue("User-Agent", "NTRIP BNC/1.7"); 93 94 QByteArray userAndPwd = "Basic " + QByteArray("cvutlukes:monitoring").toBase64(); 95 header.addValue("Authorization", userAndPwd); 96 97 QHttp* http = new QHttp("czeposr.cuzk.cz", 2101); 98 99 connect(http, SIGNAL(readyRead(const QHttpResponseHeader&)), 100 this, SLOT(slotReadyRead())); 101 102 QBuffer buffer; 103 http->request(header, 0, &buffer); 104 105 while (true) { 106 if (buffer.bytesAvailable()) { 107 QByteArray arr = buffer.readAll(); 108 cout << arr.data(); 109 } 110 else { 111 buffer.waitForReadyRead(1000); 112 } 113 } 66 connect(_reply, SIGNAL(finished()), this, SLOT(slotReplyFinished())); 67 connect(_reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); 68 connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), 69 this, SLOT(slotError(QNetworkReply::NetworkError))); 70 connect(_reply, SIGNAL(sslErrors()), this, SLOT(slotSslErrors())); 114 71 115 72 … … 119 76 // 120 77 //////////////////////////////////////////////////////////////////////////// 121 void bncNetRequest::slotReplyFinished( QNetworkReply*) {78 void bncNetRequest::slotReplyFinished() { 122 79 cout << "slotReplyFinished" << endl; 123 80 this->deleteLater(); … … 141 98 // 142 99 //////////////////////////////////////////////////////////////////////////// 143 void bncNetRequest::slotSslErrors( QList<QSslError>) {100 void bncNetRequest::slotSslErrors() { 144 101 cout << "slotSslError" << endl; 145 102 } -
trunk/BNC/bncnetrequest.h
r1294 r1335 11 11 bncNetRequest(); 12 12 ~bncNetRequest(); 13 14 t_irc request(const QUrl& mountPoint, const QByteArray& ggaStr); 13 t_irc request(const QUrl& mountPoint); 15 14 16 15 signals: 17 16 18 17 private slots: 19 void slotReplyFinished( QNetworkReply* reply);18 void slotReplyFinished(); 20 19 void slotReadyRead(); 21 20 void slotError(QNetworkReply::NetworkError); 22 void slotSslErrors( QList<QSslError>);21 void slotSslErrors(); 23 22 24 23 private:
Note:
See TracChangeset
for help on using the changeset viewer.