本文整理汇总了C++中process::DataDecoder方法的典型用法代码示例。如果您正苦于以下问题:C++ process::DataDecoder方法的具体用法?C++ process::DataDecoder怎么用?C++ process::DataDecoder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类process
的用法示例。
在下文中一共展示了process::DataDecoder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DataDecoder
TEST(DecoderTest, Request)
{
Try<Socket> socket = Socket::create();
ASSERT_SOME(socket);
DataDecoder decoder = DataDecoder(socket.get());
const string data =
"GET /path/file.json?key1=value1&key2=value2#fragment HTTP/1.1\r\n"
"Host: localhost\r\n"
"Connection: close\r\n"
"Accept-Encoding: compress, gzip\r\n"
"\r\n";
deque<http::Request*> requests = decoder.decode(data.data(), data.length());
ASSERT_FALSE(decoder.failed());
ASSERT_EQ(1, requests.size());
Owned<http::Request> request(requests[0]);
EXPECT_EQ("GET", request->method);
EXPECT_EQ("/path/file.json", request->url.path);
EXPECT_SOME_EQ("fragment", request->url.fragment);
EXPECT_EQ(2u, request->url.query.size());
EXPECT_SOME_EQ("value1", request->url.query.get("key1"));
EXPECT_SOME_EQ("value2", request->url.query.get("key2"));
EXPECT_TRUE(request->body.empty());
EXPECT_FALSE(request->keepAlive);
EXPECT_EQ(3u, request->headers.size());
EXPECT_SOME_EQ("localhost", request->headers.get("Host"));
EXPECT_SOME_EQ("close", request->headers.get("Connection"));
EXPECT_SOME_EQ("compress, gzip", request->headers.get("Accept-Encoding"));
}