Changeset 1593 in ntrip
- Timestamp:
- Feb 13, 2009, 6:15:22 PM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncnetqueryv1.cpp
r1592 r1593 65 65 } 66 66 else if (!_socket->waitForReadyRead(_timeOut)) { 67 QString errStr = _socket->errorString(); 68 if (errStr.isEmpty()) { 69 errStr = "Read timeout"; 70 } 67 71 delete _socket; 68 72 _socket = 0; 69 73 _status = error; 70 emit newMessage(_url.path().toAscii() + ": Read timeout", true);74 emit newMessage(_url.path().toAscii() + ": " + errStr.toAscii(), true); 71 75 return; 72 76 } … … 158 162 QStringList response; 159 163 while (true) { 160 QByteArray line = this->readNextLine(); 161 if (_status == error) { 162 break; 164 if (_socket->canReadLine()) { 165 QString line = _socket->readLine(); 166 167 if (line.indexOf("ICY 200 OK") == -1 && 168 line.indexOf("HTTP") != -1 && 169 line.indexOf("200 OK") != -1 ) { 170 proxyResponse = true; 171 } 172 173 if (!proxyResponse && !line.trimmed().isEmpty()) { 174 response.push_back(line); 175 } 176 177 if (line.trimmed().isEmpty()) { 178 if (proxyResponse) { 179 proxyResponse = false; 180 } 181 else { 182 break; 183 } 184 } 185 186 if (line.indexOf("Unauthorized") != -1) { 187 break; 188 } 189 190 if (!proxyResponse && 191 line.indexOf("200 OK") != -1 && 192 line.indexOf("SOURCETABLE") == -1) { 193 response.clear(); 194 } 163 195 } 164 165 if (line.indexOf("ICY 200 OK") == -1 && 166 line.indexOf("HTTP") != -1 && 167 line.indexOf("200 OK") != -1 ) { 168 proxyResponse = true; 169 } 170 171 cout << proxyResponse << ": " << line.data(); cout.flush(); 172 173 if (!proxyResponse && !line.trimmed().isEmpty()) { 174 response.push_back(line); 175 } 176 177 if (line.indexOf("Unauthorized") != -1) { 178 break; 179 } 180 181 if (line.trimmed().isEmpty()) { 182 if (proxyResponse) { 183 proxyResponse = false; 184 } 185 else { 186 break; 187 } 188 } 189 190 if (!proxyResponse && 191 line.indexOf("200 OK") != -1 && 192 line.indexOf("SOURCETABLE") == -1) { 193 response.clear(); 194 break; 196 else if (!_socket->waitForReadyRead(_timeOut)) { 197 delete _socket; 198 _socket = 0; 199 _status = error; 200 emit newMessage(_url.path().toAscii() + ": Response timeout", true); 201 return; 195 202 } 196 203 } … … 204 211 } 205 212 206 //207 ////////////////////////////////////////////////////////////////////////////208 QByteArray bncNetQueryV1::readNextLine() {209 QByteArray buffer;210 char ch1 = ' ';211 while (true) {212 if (_socket->bytesAvailable()) {213 char ch2;214 _socket->read(&ch2, 1);215 if (ch2 != '\r') {216 buffer += ch2;217 }218 if ( (ch2 == '\n' && ch1 == '\r') ||219 (ch2 == '\r' && ch1 == '\n') ) {220 return buffer;221 }222 ch1 = ch2;223 }224 else if (!_socket->waitForReadyRead(_timeOut)) {225 delete _socket;226 _socket = 0;227 _status = error;228 emit newMessage(_url.path().toAscii() + ": Response timeout", true);229 return "";230 }231 }232 }233 -
trunk/BNC/bncnetqueryv1.h
r1592 r1593 15 15 16 16 private: 17 QByteArray readNextLine();18 17 QTcpSocket* _socket; 19 18 };
Note:
See TracChangeset
for help on using the changeset viewer.