Changeset 1591 in ntrip
- Timestamp:
- Feb 13, 2009, 5:33:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncnetqueryv1.cpp
r1589 r1591 158 158 QStringList response; 159 159 while (true) { 160 if (!_socket->waitForReadyRead(_timeOut)) { 161 delete _socket; 162 _socket = 0; 163 _status = error; 164 emit newMessage(_url.path().toAscii() + ": Response timeout", true); 165 return; 166 } 167 if (_socket->canReadLine()) { 168 QString line = _socket->readLine(); 169 170 if (line.indexOf("ICY 200 OK") == -1 && 171 line.indexOf("HTTP") != -1 && 172 line.indexOf("200 OK") != -1 ) { 173 proxyResponse = true; 174 } 175 176 if (!proxyResponse) { 177 response.push_back(line); 178 } 179 180 if (line.indexOf("Unauthorized") != -1) { 160 QByteArray line = this->readNextLine(); 161 if (_status == error) { 162 break; 163 } 164 165 cout << ">" << line.data() << "<"; cout.flush(); 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.indexOf("Unauthorized") != -1) { 178 break; 179 } 180 181 if (line.trimmed().isEmpty()) { 182 if (proxyResponse) { 183 proxyResponse = false; 184 } 185 else { 181 186 break; 182 } 183 184 if (line.trimmed().isEmpty()) { 185 if (proxyResponse) { 186 proxyResponse = false; 187 } 188 else { 189 break; 190 } 191 } 192 193 if (!proxyResponse && 194 line.indexOf("200 OK") != -1 && 195 line.indexOf("SOURCETABLE") == -1) { 196 response.clear(); 197 break; 198 } 187 } 188 } 189 190 if (!proxyResponse && 191 line.indexOf("200 OK") != -1 && 192 line.indexOf("SOURCETABLE") == -1) { 193 response.clear(); 194 break; 199 195 } 200 196 } … … 208 204 } 209 205 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
Note:
See TracChangeset
for help on using the changeset viewer.