Changeset 1385 in ntrip


Ignore:
Timestamp:
Dec 29, 2008, 10:01:30 AM (15 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncnetqueryv1.cpp

    r1384 r1385  
    1818#include <iomanip>
    1919
    20 #include "bncsocket.h"
    21 #include "bncapp.h"
    22 #include "bncutils.h"
     20#include "bncnetqueryv1.h"
    2321
    2422using namespace std;
     
    5351void bncNetQueryV1::startRequest(const QUrl& url, const QByteArray& gga) {
    5452
     53  const int timeOut = 5000;
     54
     55  _status = running;
     56
    5557  delete _socket;
    5658  _socket = new QTcpSocket();
     59
     60  // Default scheme and path
     61  // -----------------------
     62  QUrl urlLoc(url);
     63  if (urlLoc.scheme().isEmpty()) {
     64    urlLoc.setScheme("http");
     65  }
     66  if (urlLoc.path().isEmpty()) {
     67    urlLoc.setPath("/");
     68  }
    5769
    5870  // Connect the Socket
     
    6375 
    6476  if ( proxyHost.isEmpty() ) {
    65     _socket->connectToHost(mountPoint.host(), mountPoint.port());
     77    _socket->connectToHost(urlLoc.host(), urlLoc.port());
    6678  }
    6779  else {
     
    6981  }
    7082  if (!_socket->waitForConnected(timeOut)) {
    71     msg += "Connect timeout\n";
    7283    delete _socket;
    7384    _socket = 0;
    74     return failure;
     85    _status = error;
     86    return;
    7587  }
    7688
    7789  // Send Request
    7890  // ------------
    79   QString uName = QUrl::fromPercentEncoding(mountPoint.userName().toAscii());
    80   QString passW = QUrl::fromPercentEncoding(mountPoint.password().toAscii());
     91  QString uName = QUrl::fromPercentEncoding(urlLoc.userName().toAscii());
     92  QString passW = QUrl::fromPercentEncoding(urlLoc.password().toAscii());
    8193  QByteArray userAndPwd;
    8294
    83   if(!uName.isEmpty() || !passW.isEmpty())
    84   {
     95  if(!uName.isEmpty() || !passW.isEmpty()) {
    8596    userAndPwd = "Authorization: Basic " + (uName.toAscii() + ":" +
    8697    passW.toAscii()).toBase64() + "\r\n";
    8798  }
    8899
    89   QUrl hlp;
    90   hlp.setScheme("http");
    91   hlp.setHost(mountPoint.host());
    92   hlp.setPort(mountPoint.port());
    93   hlp.setPath(mountPoint.path());
    94 
    95100  QByteArray reqStr;
    96101  if ( proxyHost.isEmpty() ) {
    97     if (hlp.path().indexOf("/") != 0) hlp.setPath("/");
    98     reqStr = "GET " + hlp.path().toAscii() + " HTTP/1.0\r\n"
     102    if (urlLoc.path().indexOf("/") != 0) urlLoc.setPath("/");
     103    reqStr = "GET " + urlLoc.path().toAscii() + " HTTP/1.0\r\n"
    99104             + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n"
    100105             + userAndPwd + "\r\n";
    101106  } else {
    102     reqStr = "GET " + hlp.toEncoded() + " HTTP/1.0\r\n"
     107    reqStr = "GET " + urlLoc.toEncoded() + " HTTP/1.0\r\n"
    103108             + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n"
    104              + "Host: " + hlp.host().toAscii() + "\r\n"
     109             + "Host: " + urlLoc.host().toAscii() + "\r\n"
    105110             + userAndPwd + "\r\n";
    106111  }
     
    108113  // NMEA string to handle VRS stream
    109114  // --------------------------------
    110   if ((nmea == "yes") && (hlp.path().length() > 2) && (hlp.path().indexOf(".skl") < 0)) {
    111     reqStr += ggaString(latitude, longitude) + "\r\n";
     115  if (!gga.isEmpty()) {
     116    reqStr += gga + "\r\n";
    112117  }
    113 
    114   msg += reqStr;
    115118
    116119  _socket->write(reqStr, reqStr.length());
    117120
    118121  if (!_socket->waitForBytesWritten(timeOut)) {
    119     msg += "Write timeout\n";
    120122    delete _socket;
    121123    _socket = 0;
    122     return failure;
     124    _status = error;
    123125  }
    124 
    125   return success;
    126126}
    127127
Note: See TracChangeset for help on using the changeset viewer.