Changeset 1500 in ntrip


Ignore:
Timestamp:
Jan 18, 2009, 3:14:30 PM (14 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bnc.pro

    r1428 r1500  
    22# Switch to debug configuration
    33# -----------------------------
    4 CONFIG -= debug
    5 CONFIG += release
     4CONFIG -= release
     5CONFIG += debug
    66
    77DEFINES += NO_RTCM3_MAIN
  • trunk/BNC/bncnetquery.h

    r1499 r1500  
    3333  queryStatus _status;
    3434  int         _timeOut;
     35  QUrl        _url;
    3536};
    3637
  • trunk/BNC/bncnetqueryv1.cpp

    r1498 r1500  
    2727////////////////////////////////////////////////////////////////////////////
    2828bncNetQueryV1::bncNetQueryV1() {
    29   _socket = 0;
     29  _socket  = 0;
     30  _timeOut = 20000;
    3031}
    3132
     
    5556////////////////////////////////////////////////////////////////////////////
    5657void 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      }
    6072    }
    6173  }
     
    6678void bncNetQueryV1::startRequest(const QUrl& url, const QByteArray& gga) {
    6779
    68   const int timeOut = 20000;
    69 
    7080  _status = running;
    7181
     
    7585  // Default scheme and path
    7686  // -----------------------
    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");
    8090  }
    81   if (urlLoc.path().isEmpty()) {
    82     urlLoc.setPath("/");
     91  if (_url.path().isEmpty()) {
     92    _url.setPath("/");
    8393  }
    8494
     
    90100 
    91101  if ( proxyHost.isEmpty() ) {
    92     _socket->connectToHost(urlLoc.host(), urlLoc.port());
     102    _socket->connectToHost(_url.host(), _url.port());
    93103  }
    94104  else {
    95105    _socket->connectToHost(proxyHost, proxyPort);
    96106  }
    97   if (!_socket->waitForConnected(timeOut)) {
     107  if (!_socket->waitForConnected(_timeOut)) {
    98108    delete _socket;
    99109    _socket = 0;
     
    104114  // Send Request
    105115  // ------------
    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());
    108118  QByteArray userAndPwd;
    109119
     
    115125  QByteArray reqStr;
    116126  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"
    119129             + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n"
    120130             + userAndPwd + "\r\n";
    121131  } else {
    122     reqStr = "GET " + urlLoc.toEncoded() + " HTTP/1.0\r\n"
     132    reqStr = "GET " + _url.toEncoded() + " HTTP/1.0\r\n"
    123133             + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n"
    124              + "Host: " + urlLoc.host().toAscii() + "\r\n"
     134             + "Host: " + _url.host().toAscii() + "\r\n"
    125135             + userAndPwd + "\r\n";
    126136  }
     
    134144  _socket->write(reqStr, reqStr.length());
    135145
    136   if (!_socket->waitForBytesWritten(timeOut)) {
     146  if (!_socket->waitForBytesWritten(_timeOut)) {
    137147    delete _socket;
    138148    _socket = 0;
    139149    _status = error;
    140     emit newMessage("bncnetqueryv1: write timeout", true);
     150    emit newMessage(_url.path().toAscii() + " write timeout", true);
    141151    return;
    142152  }
     
    145155  // --------------------
    146156  while (true) {
    147     if (!_socket->waitForReadyRead(timeOut)) {
     157    if (!_socket->waitForReadyRead(_timeOut)) {
    148158      delete _socket;
    149159      _socket = 0;
    150160      _status = error;
    151       emit newMessage("bncnetqueryv1: read timeout", true);
     161      emit newMessage(_url.path().toAscii() + " read timeout", true);
    152162      return;
    153163    }
    154164    if (_socket->canReadLine()) {
    155165      QString line = _socket->readLine();
    156       cout << ">" << line.toAscii().data() << "<" << endl;
    157166      if (line.indexOf("ICY 200 OK") != -1) {
    158167        break;
Note: See TracChangeset for help on using the changeset viewer.