本文整理汇总了C++中HTTPResponse::getChunkedTransferEncoding方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPResponse::getChunkedTransferEncoding方法的具体用法?C++ HTTPResponse::getChunkedTransferEncoding怎么用?C++ HTTPResponse::getChunkedTransferEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPResponse
的用法示例。
在下文中一共展示了HTTPResponse::getChunkedTransferEncoding方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testPostLargeChunkedKeepAlive
void HTTPSClientSessionTest::testPostLargeChunkedKeepAlive()
{
SecureServerSocket svs(32322);
HTTPServer srv(new TestRequestHandlerFactory(), svs, new HTTPServerParams());
srv.start();
try
{
HTTPSClientSession s("localhost", srv.port());
s.setKeepAlive(true);
for (int i = 0; i < 10; ++i)
{
HTTPRequest request(HTTPRequest::HTTP_POST, "/keepAlive", HTTPMessage::HTTP_1_1);
std::string body(16000, 'x');
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);
}
srv.stop();
}
catch (...)
{
srv.stop();
throw;
}
}
示例2: s
TEST(HTTPClientSession, testPostLargeClose)
{
HTTPClientSession s("localhost", 80);
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
std::string body(8000, 'x');
s.sendRequest(request) << body;
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
EXPECT_TRUE (!response.getChunkedTransferEncoding());
EXPECT_TRUE (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
std::ostringstream ostr;
StreamCopier::copyStream(rs, ostr);
EXPECT_TRUE (ostr.str() == body);
}
示例3: testPostLargeClose
void HTTPSClientSessionTest::testPostLargeClose()
{
HTTPSTestServer srv;
HTTPSClientSession s("localhost", srv.port());
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
std::string body(8000, 'x');
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);
}
示例4: 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);
}
示例5: testKeepAlive
void HTTPSClientSessionTest::testKeepAlive()
{
HTTPSTestServer srv;
HTTPSClientSession s("localhost", srv.port());
s.setKeepAlive(true);
HTTPRequest request(HTTPRequest::HTTP_HEAD, "/keepAlive", HTTPMessage::HTTP_1_1);
s.sendRequest(request);
HTTPResponse response;
std::istream& rs1 = s.receiveResponse(response);
assert (response.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
assert (response.getContentType() == "text/plain");
assert (response.getKeepAlive());
std::ostringstream ostr1;
assert (StreamCopier::copyStream(rs1, ostr1) == 0);
request.setMethod(HTTPRequest::HTTP_GET);
request.setURI("/small");
s.sendRequest(request);
std::istream& rs2 = s.receiveResponse(response);
assert (response.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
assert (response.getKeepAlive());
std::ostringstream ostr2;
StreamCopier::copyStream(rs2, ostr2);
assert (ostr2.str() == HTTPSTestServer::SMALL_BODY);
request.setMethod(HTTPRequest::HTTP_GET);
request.setURI("/large");
s.sendRequest(request);
std::istream& rs3 = s.receiveResponse(response);
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);
assert (response.getChunkedTransferEncoding());
assert (response.getKeepAlive());
std::ostringstream ostr3;
int n = StreamCopier::copyStream(rs3, ostr3);
assert (ostr3.str() == HTTPSTestServer::LARGE_BODY);
request.setMethod(HTTPRequest::HTTP_HEAD);
request.setURI("/large");
s.sendRequest(request);
std::istream& rs4= s.receiveResponse(response);
assert (response.getContentLength() == HTTPSTestServer::LARGE_BODY.length());
assert (response.getContentType() == "text/plain");
assert (!response.getKeepAlive());
std::ostringstream ostr4;
assert (StreamCopier::copyStream(rs4, ostr4) == 0);
}