Changeset 1385 in ntrip
- Timestamp:
- Dec 29, 2008, 10:01:30 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncnetqueryv1.cpp
r1384 r1385 18 18 #include <iomanip> 19 19 20 #include "bncsocket.h" 21 #include "bncapp.h" 22 #include "bncutils.h" 20 #include "bncnetqueryv1.h" 23 21 24 22 using namespace std; … … 53 51 void bncNetQueryV1::startRequest(const QUrl& url, const QByteArray& gga) { 54 52 53 const int timeOut = 5000; 54 55 _status = running; 56 55 57 delete _socket; 56 58 _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 } 57 69 58 70 // Connect the Socket … … 63 75 64 76 if ( proxyHost.isEmpty() ) { 65 _socket->connectToHost( mountPoint.host(), mountPoint.port());77 _socket->connectToHost(urlLoc.host(), urlLoc.port()); 66 78 } 67 79 else { … … 69 81 } 70 82 if (!_socket->waitForConnected(timeOut)) { 71 msg += "Connect timeout\n";72 83 delete _socket; 73 84 _socket = 0; 74 return failure; 85 _status = error; 86 return; 75 87 } 76 88 77 89 // Send Request 78 90 // ------------ 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()); 81 93 QByteArray userAndPwd; 82 94 83 if(!uName.isEmpty() || !passW.isEmpty()) 84 { 95 if(!uName.isEmpty() || !passW.isEmpty()) { 85 96 userAndPwd = "Authorization: Basic " + (uName.toAscii() + ":" + 86 97 passW.toAscii()).toBase64() + "\r\n"; 87 98 } 88 99 89 QUrl hlp;90 hlp.setScheme("http");91 hlp.setHost(mountPoint.host());92 hlp.setPort(mountPoint.port());93 hlp.setPath(mountPoint.path());94 95 100 QByteArray reqStr; 96 101 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" 99 104 + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n" 100 105 + userAndPwd + "\r\n"; 101 106 } else { 102 reqStr = "GET " + hlp.toEncoded() + " HTTP/1.0\r\n"107 reqStr = "GET " + urlLoc.toEncoded() + " HTTP/1.0\r\n" 103 108 + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n" 104 + "Host: " + hlp.host().toAscii() + "\r\n"109 + "Host: " + urlLoc.host().toAscii() + "\r\n" 105 110 + userAndPwd + "\r\n"; 106 111 } … … 108 113 // NMEA string to handle VRS stream 109 114 // -------------------------------- 110 if ( (nmea == "yes") && (hlp.path().length() > 2) && (hlp.path().indexOf(".skl") < 0)) {111 reqStr += gga String(latitude, longitude)+ "\r\n";115 if (!gga.isEmpty()) { 116 reqStr += gga + "\r\n"; 112 117 } 113 114 msg += reqStr;115 118 116 119 _socket->write(reqStr, reqStr.length()); 117 120 118 121 if (!_socket->waitForBytesWritten(timeOut)) { 119 msg += "Write timeout\n";120 122 delete _socket; 121 123 _socket = 0; 122 return failure;124 _status = error; 123 125 } 124 125 return success;126 126 } 127 127
Note:
See TracChangeset
for help on using the changeset viewer.