本文整理汇总了C++中HTTPSTestServer类的典型用法代码示例。如果您正苦于以下问题:C++ HTTPSTestServer类的具体用法?C++ HTTPSTestServer怎么用?C++ HTTPSTestServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTTPSTestServer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uri
void HTTPSStreamFactoryTest::testRedirect()
{
HTTPSTestServer server;
HTTPSStreamFactory factory;
URI uri("https://localhost/redirect");
uri.setPort(server.port());
std::auto_ptr<std::istream> pStr(factory.open(uri));
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
}
示例2: s
void HTTPSClientSessionTest::testUnknownContentLength()
{
HTTPSTestServer srv;
HTTPSClientSession s("127.0.0.1", srv.port());
HTTPRequest request(HTTPRequest::HTTP_GET, "/nolength");
s.sendRequest(request);
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
assert (response.getContentType() == "text/plain");
std::ostringstream ostr;
StreamCopier::copyStream(rs, ostr);
assert (ostr.str() == HTTPSTestServer::SMALL_BODY);
}
示例3: uri
void HTTPSStreamFactoryTest::testRedirect()
{
HTTPSTestServer server;
HTTPSStreamFactory factory;
URI uri("https://127.0.0.1/redirect");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
}
示例4: testError
void HTTPSStreamFactoryTest::testError()
{
HTTPSTestServer server;
HTTPSStreamFactory factory;
URI uri("https://localhost/notfound");
uri.setPort(server.port());
try
{
std::istream* pStr = factory.open(uri);
fail("not found - must throw");
}
catch (HTTPException& exc)
{
std::string m = exc.displayText();
}
}
示例5: testPostSmallChunked
void HTTPSClientSessionTest::testPostSmallChunked()
{
HTTPSTestServer srv;
HTTPSClientSession s("127.0.0.1", srv.port());
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
std::string body("this is a random request body");
request.setChunkedTransferEncoding(true);
s.sendRequest(request) << body;
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
assert (response.getChunkedTransferEncoding());
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
std::ostringstream ostr;
StreamCopier::copyStream(rs, ostr);
assert (ostr.str() == body);
}
示例6: testPostLargeIdentity
void HTTPSClientSessionTest::testPostLargeIdentity()
{
HTTPSTestServer srv;
HTTPSClientSession s("127.0.0.1", srv.port());
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
std::string body(8000, 'x');
body.append("\r\n0\r\n");
request.setContentLength((int) body.length());
s.sendRequest(request) << body;
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
assert (response.getContentLength() == body.length());
std::ostringstream ostr;
StreamCopier::copyStream(rs, ostr);
assert (ostr.str() == body);
}