Changeset 1275 in ntrip


Ignore:
Timestamp:
Dec 5, 2008, 5:06:54 PM (15 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncgetthread.cpp

    r1272 r1275  
    226226  // Connect the Socket
    227227  // ------------------
    228   QSettings settings;
    229   QString proxyHost = settings.value("proxyHost").toString();
    230   int     proxyPort = settings.value("proxyPort").toInt();
    231  
    232228  QTcpSocket* socket = new QTcpSocket();
    233   if ( proxyHost.isEmpty() ) {
    234     socket->connectToHost(mountPoint.host(), mountPoint.port());
    235   }
    236   else {
    237     socket->connectToHost(proxyHost, proxyPort);
    238   }
     229
     230  socket->connectToHost(mountPoint.host(), mountPoint.port());
     231
    239232  if (!socket->waitForConnected(timeOut)) {
    240233    msg += "Connect timeout\n";
     
    242235    return 0;
    243236  }
     237
     238  // Set Proxy (application-wide)
     239  // ----------------------------
     240  QSettings settings;
     241  QString proxyHost = settings.value("proxyHost").toString();
     242  int     proxyPort = settings.value("proxyPort").toInt();
     243
     244  QNetworkProxy proxy;
     245  if (proxyHost.isEmpty()) {
     246    proxy.setType(QNetworkProxy::NoProxy);
     247  }
     248  else {
     249    proxy.setType(QNetworkProxy::Socks5Proxy);
     250    proxy.setHostName(proxyHost);
     251    proxy.setPort(proxyPort);
     252  }
     253  QNetworkProxy::setApplicationProxy(proxy);
    244254
    245255  // Send Request
     
    260270  hlp.setPort(mountPoint.port());
    261271  hlp.setPath(mountPoint.path());
    262 
    263   QByteArray reqStr;
    264   if ( proxyHost.isEmpty() ) {
    265     if (hlp.path().indexOf("/") != 0) {
    266       hlp.setPath("/");
    267     }
    268     reqStr = "GET " + hlp.path().toAscii() + " HTTP/1.0\r\n";
    269   } else {
    270     reqStr = "GET " + hlp.toEncoded() + " HTTP/1.0\r\n";
    271   }
    272   reqStr += "User-Agent: NTRIP BNC/" AGENTVERSION "\r\n"
    273             "Host: " + hlp.host().toAscii() + "\r\n"
    274             + userAndPwd + "\r\n";
     272  if (hlp.path().indexOf("/") != 0) {
     273    hlp.setPath("/");
     274  }
     275 
     276  QByteArray reqStr = "GET " + hlp.path().toAscii() + " HTTP/1.0\r\n" +
     277                      "User-Agent: NTRIP BNC/" AGENTVERSION "\r\n"
     278                      "Host: " + hlp.host().toAscii() + "\r\n"
     279                      + userAndPwd + "\r\n";
    275280
    276281  // NMEA string to handle VRS stream
Note: See TracChangeset for help on using the changeset viewer.