Changeset 1500 in ntrip
- Timestamp:
- Jan 18, 2009, 3:14:30 PM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnc.pro
r1428 r1500 2 2 # Switch to debug configuration 3 3 # ----------------------------- 4 CONFIG -= debug5 CONFIG += release4 CONFIG -= release 5 CONFIG += debug 6 6 7 7 DEFINES += NO_RTCM3_MAIN -
trunk/BNC/bncnetquery.h
r1499 r1500 33 33 queryStatus _status; 34 34 int _timeOut; 35 QUrl _url; 35 36 }; 36 37 -
trunk/BNC/bncnetqueryv1.cpp
r1498 r1500 27 27 //////////////////////////////////////////////////////////////////////////// 28 28 bncNetQueryV1::bncNetQueryV1() { 29 _socket = 0; 29 _socket = 0; 30 _timeOut = 20000; 30 31 } 31 32 … … 55 56 //////////////////////////////////////////////////////////////////////////// 56 57 void bncNetQueryV1::waitForReadyRead(QByteArray& outData) { 57 if (_socket) { 58 if (_socket->waitForReadyRead()) { 59 outData = _socket->readAll(); 58 if (_socket && _socket->state() == QAbstractSocket::ConnectedState) { 59 while (true) { 60 int nBytes = _socket->bytesAvailable(); 61 if (nBytes > 0) { 62 outData = _socket->readAll(); 63 return; 64 } 65 else if (!_socket->waitForReadyRead(_timeOut)) { 66 delete _socket; 67 _socket = 0; 68 _status = error; 69 emit newMessage(_url.path().toAscii() + " read timeout", true); 70 return; 71 } 60 72 } 61 73 } … … 66 78 void bncNetQueryV1::startRequest(const QUrl& url, const QByteArray& gga) { 67 79 68 const int timeOut = 20000;69 70 80 _status = running; 71 81 … … 75 85 // Default scheme and path 76 86 // ----------------------- 77 QUrl urlLoc(url);78 if ( urlLoc.scheme().isEmpty()) {79 urlLoc.setScheme("http");87 _url = url; 88 if (_url.scheme().isEmpty()) { 89 _url.setScheme("http"); 80 90 } 81 if ( urlLoc.path().isEmpty()) {82 urlLoc.setPath("/");91 if (_url.path().isEmpty()) { 92 _url.setPath("/"); 83 93 } 84 94 … … 90 100 91 101 if ( proxyHost.isEmpty() ) { 92 _socket->connectToHost( urlLoc.host(), urlLoc.port());102 _socket->connectToHost(_url.host(), _url.port()); 93 103 } 94 104 else { 95 105 _socket->connectToHost(proxyHost, proxyPort); 96 106 } 97 if (!_socket->waitForConnected( timeOut)) {107 if (!_socket->waitForConnected(_timeOut)) { 98 108 delete _socket; 99 109 _socket = 0; … … 104 114 // Send Request 105 115 // ------------ 106 QString uName = QUrl::fromPercentEncoding( urlLoc.userName().toAscii());107 QString passW = QUrl::fromPercentEncoding( urlLoc.password().toAscii());116 QString uName = QUrl::fromPercentEncoding(_url.userName().toAscii()); 117 QString passW = QUrl::fromPercentEncoding(_url.password().toAscii()); 108 118 QByteArray userAndPwd; 109 119 … … 115 125 QByteArray reqStr; 116 126 if ( proxyHost.isEmpty() ) { 117 if ( urlLoc.path().indexOf("/") != 0) urlLoc.setPath("/");118 reqStr = "GET " + urlLoc.path().toAscii() + " HTTP/1.0\r\n"127 if (_url.path().indexOf("/") != 0) _url.setPath("/"); 128 reqStr = "GET " + _url.path().toAscii() + " HTTP/1.0\r\n" 119 129 + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n" 120 130 + userAndPwd + "\r\n"; 121 131 } else { 122 reqStr = "GET " + urlLoc.toEncoded() + " HTTP/1.0\r\n"132 reqStr = "GET " + _url.toEncoded() + " HTTP/1.0\r\n" 123 133 + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n" 124 + "Host: " + urlLoc.host().toAscii() + "\r\n"134 + "Host: " + _url.host().toAscii() + "\r\n" 125 135 + userAndPwd + "\r\n"; 126 136 } … … 134 144 _socket->write(reqStr, reqStr.length()); 135 145 136 if (!_socket->waitForBytesWritten( timeOut)) {146 if (!_socket->waitForBytesWritten(_timeOut)) { 137 147 delete _socket; 138 148 _socket = 0; 139 149 _status = error; 140 emit newMessage( "bncnetqueryv1:write timeout", true);150 emit newMessage(_url.path().toAscii() + " write timeout", true); 141 151 return; 142 152 } … … 145 155 // -------------------- 146 156 while (true) { 147 if (!_socket->waitForReadyRead( timeOut)) {157 if (!_socket->waitForReadyRead(_timeOut)) { 148 158 delete _socket; 149 159 _socket = 0; 150 160 _status = error; 151 emit newMessage( "bncnetqueryv1:read timeout", true);161 emit newMessage(_url.path().toAscii() + " read timeout", true); 152 162 return; 153 163 } 154 164 if (_socket->canReadLine()) { 155 165 QString line = _socket->readLine(); 156 cout << ">" << line.toAscii().data() << "<" << endl;157 166 if (line.indexOf("ICY 200 OK") != -1) { 158 167 break;
Note:
See TracChangeset
for help on using the changeset viewer.