mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 11:06:50 +01:00
fixed GH #1472: HTTP(S)StreamFactory should send a User-Agent header
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
#include "Poco/UnbufferedStreamBuf.h"
|
||||
#include "Poco/NullStream.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/Version.h"
|
||||
|
||||
|
||||
using Poco::URIStreamFactory;
|
||||
@@ -115,6 +117,12 @@ std::istream* HTTPStreamFactory::open(const URI& uri)
|
||||
cred.authenticate(req, res);
|
||||
}
|
||||
|
||||
req.set("User-Agent", Poco::format("poco/%d.%d.%d",
|
||||
(POCO_VERSION >> 24) & 0xFF,
|
||||
(POCO_VERSION >> 16) & 0xFF,
|
||||
(POCO_VERSION >> 8) & 0xFF));
|
||||
req.set("Accept", "*/*");
|
||||
|
||||
pSession->sendRequest(req);
|
||||
std::istream& rs = pSession->receiveResponse(res);
|
||||
bool moved = (res.getStatus() == HTTPResponse::HTTP_MOVED_PERMANENTLY ||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "Poco/UnbufferedStreamBuf.h"
|
||||
#include "Poco/NullStream.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/Version.h"
|
||||
|
||||
|
||||
using Poco::URIStreamFactory;
|
||||
@@ -118,6 +120,12 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
||||
cred.authenticate(req, res);
|
||||
}
|
||||
|
||||
req.set("User-Agent", Poco::format("poco/%d.%d.%d",
|
||||
(POCO_VERSION >> 24) & 0xFF,
|
||||
(POCO_VERSION >> 16) & 0xFF,
|
||||
(POCO_VERSION >> 8) & 0xFF));
|
||||
req.set("Accept", "*/*");
|
||||
|
||||
pSession->sendRequest(req);
|
||||
std::istream& rs = pSession->receiveResponse(res);
|
||||
bool moved = (res.getStatus() == HTTPResponse::HTTP_MOVED_PERMANENTLY ||
|
||||
|
||||
Reference in New Issue
Block a user