以下代码在Internet选项中设置的代理环境中不起作用。 POCO库的例子不显示,怎么办。有没有解决方法? 我使用最新的POCO库如何在代理环境中使用Poco C++(使用HTTPStreamFactory)
using Poco::URIStreamOpener;
using Poco::StreamCopier;
using Poco::Path;
using Poco::URI;
using Poco::SharedPtr;
using Poco::Exception;
using Poco::Net::HTTPStreamFactory;
using Poco::Net::FTPStreamFactory;
class WebInitializer
{
public:
WebInitializer()
{
HTTPStreamFactory::registerFactory();
FTPStreamFactory::registerFactory();
}
~WebInitializer()
{
HTTPStreamFactory::unregisterFactory();
FTPStreamFactory::unregisterFactory();
}
};
void Download(std::string host, std::string path, std::string targetFilePath)
{
WebInitializer webInitializer;
std::string sUrl = host + path;
URI uri(sUrl);
std::shared_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
ofstream outputfile;
outputfile.exceptions(std::ofstream::badbit | std::ofstream::failbit);
outputfile.open(targetFilePath, std::ios_base::binary);
StreamCopier::copyStream(*pStr.get(), outputfile);
outputfile.close();
}
感谢亚历克斯,什么是“MYPROXY”在这里,我必须得到系统依赖于OS,将它重定向情景工作代理字符串?有没有假设默认身份验证代理? – maniappa
“myproxy”是您的代理服务器。有关身份验证示例,请参见[testProxyAuth](https://github.com/pocoproject/poco/blob/develop/Net/testsuite/src/HTTPClientSessionTest.cpp#L262)。 – Alex
如果我的应用程序在某个客户机器上运行,我需要将他们的代理服务器名称,我说得对吗?这可能适用于我的测试案例 – maniappa