diff --git a/lib/urireader.cpp b/lib/urireader.cpp index 3e71dcf6..f65a27e9 100644 --- a/lib/urireader.cpp +++ b/lib/urireader.cpp @@ -103,6 +103,7 @@ namespace HTTP{ // Send HEAD request to determine range request is supported, and get total length downer.clearHeaders(); + if (userAgentOverride.size()){downer.setHeader("User-Agent", userAgentOverride);} if (!downer.head(myURI) || !downer.isOk()){ FAIL_MSG("Error getting URI info for '%s': %" PRIu32 " %s", myURI.getUrl().c_str(), downer.getStatusCode(), downer.getStatusText().c_str()); @@ -170,7 +171,10 @@ namespace HTTP{ /// Read all blocking function, which internally uses the Nonblocking function. void URIReader::readAll(char *&dataPtr, size_t &dataLen){ if (getSize() != std::string::npos){allData.allocate(getSize());} - while (!isEOF()){readSome(10046, *this);} + while (!isEOF()){ + readSome(10046, *this); + bufPos = allData.size(); + } dataPtr = allData; dataLen = allData.size(); } @@ -205,7 +209,7 @@ namespace HTTP{ curPos += dataLen; }else if (stateType == HTTP::HTTP){ - bool res = downer.continueNonBlocking(cb); + downer.continueNonBlocking(cb); curPos = downer.const_data().size(); }else{// streaming mode int s; diff --git a/lib/urireader.h b/lib/urireader.h index 3c46d7d1..11b34aec 100644 --- a/lib/urireader.h +++ b/lib/urireader.h @@ -62,6 +62,8 @@ namespace HTTP{ void (*httpBodyCallback)(const char *ptr, size_t size); void dataCallback(const char *ptr, size_t size); + std::string userAgentOverride; + private: // Internal state variables bool (*cbProgress)(uint8_t); ///< The progress callback, if any. Not called if set to a null pointer.