X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2FHTTPRequest.cxx;h=ce706957b6f45469b4213b9f2c6244f462830fc9;hb=adb7db9229db1d869b254ac18f1471bed464c508;hp=38651a3e9062090c9f22e2f90c2558e5a6099e83;hpb=110753e92c4d512432b93d8789348a54341dec98;p=simgear.git diff --git a/simgear/io/HTTPRequest.cxx b/simgear/io/HTTPRequest.cxx index 38651a3e..ce706957 100644 --- a/simgear/io/HTTPRequest.cxx +++ b/simgear/io/HTTPRequest.cxx @@ -112,8 +112,10 @@ string Request::path() const } int hostEnd = u.find('/', schemeEnd + 3); - if (hostEnd < 0) { - return ""; // couldn't parse host + if (hostEnd < 0) { +// couldn't parse host, or URL looks like 'http://foo.com' (no trailing '/') +// fixup to root resource path: '/' + return "/"; } int query = u.find('?', hostEnd + 1); @@ -125,6 +127,20 @@ string Request::path() const return u.substr(hostEnd, query - hostEnd); } + +string Request::query() const +{ + string u(url()); + int query = u.find('?'); + if (query < 0) { + return ""; //no query string found + } + + return u.substr(query); //includes question mark +} + + + string Request::host() const { string hp(hostAndPort()); @@ -189,6 +205,7 @@ void Request::setFailure(int code, const std::string& reason) void Request::failed() { // no-op in base class + SG_LOG(SG_IO, SG_INFO, "request failed:" << url()); } Request::HTTPVersion Request::decodeVersion(const string& v) @@ -204,6 +221,22 @@ bool Request::closeAfterComplete() const // for non HTTP/1.1 connections, assume server closes return _willClose || (_responseVersion != HTTP_1_1); } + +int Request::requestBodyLength() const +{ + return -1; +} + +std::string Request::requestBodyType() const +{ + return "text/plain"; +} + +void Request::getBodyData(char*, int& count) const +{ + count = 0; + return; +} } // of namespace HTTP