本文整理汇总了C++中URI::setHost方法的典型用法代码示例。如果您正苦于以下问题:C++ URI::setHost方法的具体用法?C++ URI::setHost怎么用?C++ URI::setHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URI
的用法示例。
在下文中一共展示了URI::setHost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testMissingPasswordProvider
void FTPStreamFactoryTest::testMissingPasswordProvider()
{
FTPStreamFactory::setPasswordProvider(0);
DialogServer server;
server.addResponse("220 localhost FTP ready");
server.addResponse("221 Good bye");
URI uri;
uri.setScheme("ftp");
uri.setHost("localhost");
uri.setPort(server.port());
uri.setPath("/test.txt;type=a");
uri.setUserInfo("user");
try
{
FTPStreamFactory sf;
std::auto_ptr<std::istream> pStr(sf.open(uri));
fail("no password provider - must throw");
}
catch (FTPException&)
{
}
}
示例2: testDownload
void FTPStreamFactoryTest::testDownload()
{
FTPStreamFactory::setPasswordProvider(0);
DialogServer server;
server.addResponse("220 localhost FTP ready");
server.addResponse("331 Password required");
server.addResponse("230 Welcome");
server.addResponse("200 Type set to I");
server.addResponse("200 Type set to A");
DialogServer dataServer(false);
dataServer.addResponse("line1\r\nline2");
std::ostringstream epsv;
epsv << "229 Entering Extended Passive Mode (|||" << dataServer.port() << "|)";
server.addResponse(epsv.str());
server.addResponse("150 sending data\r\n226 Transfer complete");
server.addResponse("221 Good bye");
URI uri;
uri.setScheme("ftp");
uri.setHost("localhost");
uri.setPort(server.port());
uri.setPath("/test.txt;type=a");
FTPStreamFactory sf;
std::auto_ptr<std::istream> pStr(sf.open(uri));
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assert (s == "line1\r\nline2\r\n");
}
示例3: resolve
URI Transaction::resolve(const URI &_uri) {
URI uri = _uri;
if (uri.getHost().empty()) {
uri.setHost(address.getHost());
if (uri.getScheme().empty()) uri.setScheme("http");
if (!uri.getPort()) uri.setPort(address.getPort());
}
return uri;
}
示例4: operator
bool RedirectSecure::operator()(Request &req) {
if (req.isSecure()) return false; // Pass it on
// Set scheme, host & port
URI uri = req.getURI();
uri.setScheme("https");
uri.setHost(IPAddress(req.getHost()).getHost());
uri.setPort(port == 443 ? 0 : port);
// Redirect
req.redirect(uri);
return true;
}