aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/fetch/httpfsm_ut.cpp
diff options
context:
space:
mode:
authorlonelly <lonelly@yandex-team.ru>2022-02-10 16:49:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:49 +0300
commite01af096d5cd7baca583319f1473a2a2c993ec86 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/http/fetch/httpfsm_ut.cpp
parentf1a86949d52e1185ed4f05de191b50386abc68f4 (diff)
downloadydb-e01af096d5cd7baca583319f1473a2a2c993ec86.tar.gz
Restoring authorship annotation for <lonelly@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/fetch/httpfsm_ut.cpp')
-rw-r--r--library/cpp/http/fetch/httpfsm_ut.cpp232
1 files changed, 116 insertions, 116 deletions
diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp
index eb8fba7821..b018e80101 100644
--- a/library/cpp/http/fetch/httpfsm_ut.cpp
+++ b/library/cpp/http/fetch/httpfsm_ut.cpp
@@ -6,8 +6,8 @@
#include <library/cpp/charset/doccodes.h>
#include <library/cpp/testing/unittest/registar.h>
-class THttpHeaderParserTestSuite: public TTestBase {
- UNIT_TEST_SUITE(THttpHeaderParserTestSuite);
+class THttpHeaderParserTestSuite: public TTestBase {
+ UNIT_TEST_SUITE(THttpHeaderParserTestSuite);
UNIT_TEST(TestRequestHeader);
UNIT_TEST(TestSplitRequestHeader);
UNIT_TEST(TestTrailingData);
@@ -30,25 +30,25 @@ class THttpHeaderParserTestSuite: public TTestBase {
UNIT_TEST(TestHreflangOnLongInput);
UNIT_TEST(TestMimeType);
UNIT_TEST(TestRepeatedContentEncoding);
- UNIT_TEST_SUITE_END();
+ UNIT_TEST_SUITE_END();
-private:
+private:
THolder<THttpHeaderParser> httpHeaderParser;
-private:
- void TestStart();
- void TestFinish();
+private:
+ void TestStart();
+ void TestFinish();
-public:
- void TestRequestHeader();
+public:
+ void TestRequestHeader();
void TestSplitRequestHeader();
void TestTrailingData();
- void TestProxyRequestHeader();
- void TestIncorrectRequestHeader();
- void TestLastModified();
- void TestLastModifiedCorrupted();
- void TestResponseHeaderOnRequest();
- void TestRequestHeaderOnResponse();
+ void TestProxyRequestHeader();
+ void TestIncorrectRequestHeader();
+ void TestLastModified();
+ void TestLastModifiedCorrupted();
+ void TestResponseHeaderOnRequest();
+ void TestRequestHeaderOnResponse();
void TestXRobotsTagUnknownTags();
void TestXRobotsTagMyBot();
void TestXRobotsTagOtherBot();
@@ -62,41 +62,41 @@ public:
void TestHreflangOnLongInput();
void TestMimeType();
void TestRepeatedContentEncoding();
-};
+};
-void THttpHeaderParserTestSuite::TestStart() {
+void THttpHeaderParserTestSuite::TestStart() {
httpHeaderParser.Reset(new THttpHeaderParser());
}
-
-void THttpHeaderParserTestSuite::TestFinish() {
+
+void THttpHeaderParserTestSuite::TestFinish() {
httpHeaderParser.Reset();
-}
-
-void THttpHeaderParserTestSuite::TestRequestHeader() {
- TestStart();
- THttpRequestHeader httpRequestHeader;
- httpHeaderParser->Init(&httpRequestHeader);
+}
+
+void THttpHeaderParserTestSuite::TestRequestHeader() {
+ TestStart();
+ THttpRequestHeader httpRequestHeader;
+ httpHeaderParser->Init(&httpRequestHeader);
const char* request = "GET /search?q=hi HTTP/1.1\r\n"
"Host: www.google.ru:8080\r\n\r\n";
- i32 result = httpHeaderParser->Execute(request, strlen(request));
- UNIT_ASSERT_EQUAL(result, 2);
- UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET);
- UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, "www.google.ru:8080"), 0);
+ i32 result = httpHeaderParser->Execute(request, strlen(request));
+ UNIT_ASSERT_EQUAL(result, 2);
+ UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET);
+ UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, "www.google.ru:8080"), 0);
UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri, "/search?q=hi");
UNIT_ASSERT_EQUAL(httpRequestHeader.GetUrl(), "http://www.google.ru:8080/search?q=hi");
- UNIT_ASSERT_EQUAL(httpHeaderParser->lastchar - request + 1,
+ UNIT_ASSERT_EQUAL(httpHeaderParser->lastchar - request + 1,
(i32)strlen(request));
- UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_response_timeout,
+ UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_response_timeout,
DEFAULT_RESPONSE_TIMEOUT);
- UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_request_priority,
+ UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_request_priority,
DEFAULT_REQUEST_PRIORITY);
- UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_sourcename, ""), 0);
+ UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_sourcename, ""), 0);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_requesttype, ""), 0);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_fetchoptions, ""), 0);
- TestFinish();
- UNIT_ASSERT_EQUAL(httpRequestHeader.max_age, DEFAULT_MAX_AGE);
-}
-
+ TestFinish();
+ UNIT_ASSERT_EQUAL(httpRequestHeader.max_age, DEFAULT_MAX_AGE);
+}
+
void THttpHeaderParserTestSuite::TestSplitRequestHeader() {
TestStart();
const char* request =
@@ -152,85 +152,85 @@ void THttpHeaderParserTestSuite::TestTrailingData() {
TestFinish();
}
-void THttpHeaderParserTestSuite::TestProxyRequestHeader() {
- TestStart();
- THttpRequestHeader httpRequestHeader;
- httpHeaderParser->Init(&httpRequestHeader);
+void THttpHeaderParserTestSuite::TestProxyRequestHeader() {
+ TestStart();
+ THttpRequestHeader httpRequestHeader;
+ httpHeaderParser->Init(&httpRequestHeader);
const char* request =
- "GET http://www.google.ru:8080/search?q=hi HTTP/1.1\r\n"
- "X-Yandex-Response-Timeout: 1000\r\n"
- "X-Yandex-Request-Priority: 2\r\n"
- "X-Yandex-Sourcename: orange\r\n"
+ "GET http://www.google.ru:8080/search?q=hi HTTP/1.1\r\n"
+ "X-Yandex-Response-Timeout: 1000\r\n"
+ "X-Yandex-Request-Priority: 2\r\n"
+ "X-Yandex-Sourcename: orange\r\n"
"X-Yandex-Requesttype: userproxy\r\n"
"X-Yandex-FetchOptions: d;c\r\n"
- "Cache-control: max-age=100\r\n"
- "If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT\r\n"
- "User-Agent: Yandex/1.01.001 (compatible; Win16; I)\r\n"
- "From: webadmin@yandex.ru\r\n\r\n";
- i32 result = httpHeaderParser->Execute(request, strlen(request));
- UNIT_ASSERT_EQUAL(result, 2);
- UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET);
- UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_response_timeout, 1000);
- UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_request_priority, 2);
+ "Cache-control: max-age=100\r\n"
+ "If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT\r\n"
+ "User-Agent: Yandex/1.01.001 (compatible; Win16; I)\r\n"
+ "From: webadmin@yandex.ru\r\n\r\n";
+ i32 result = httpHeaderParser->Execute(request, strlen(request));
+ UNIT_ASSERT_EQUAL(result, 2);
+ UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET);
+ UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_response_timeout, 1000);
+ UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_request_priority, 2);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_sourcename, "orange"), 0);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_requesttype, "userproxy"), 0);
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_fetchoptions, "d;c"), 0);
- UNIT_ASSERT_EQUAL(httpRequestHeader.max_age, 100);
- UNIT_ASSERT_VALUES_EQUAL(httpRequestHeader.if_modified_since,
+ UNIT_ASSERT_EQUAL(httpRequestHeader.max_age, 100);
+ UNIT_ASSERT_VALUES_EQUAL(httpRequestHeader.if_modified_since,
TInstant::ParseIso8601Deprecated("1994-10-29 19:43:31Z").TimeT());
UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri,
"http://www.google.ru:8080/search?q=hi");
UNIT_ASSERT(httpRequestHeader.GetUrl() ==
"http://www.google.ru:8080/search?q=hi");
- UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, ""), 0);
- UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.from, "webadmin@yandex.ru"), 0);
- UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.user_agent,
+ UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.host, ""), 0);
+ UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.from, "webadmin@yandex.ru"), 0);
+ UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.user_agent,
"Yandex/1.01.001 (compatible; Win16; I)"),
0);
- UNIT_ASSERT_EQUAL(httpHeaderParser->lastchar - request + 1,
+ UNIT_ASSERT_EQUAL(httpHeaderParser->lastchar - request + 1,
(i32)strlen(request));
- TestFinish();
-}
-
-void THttpHeaderParserTestSuite::TestIncorrectRequestHeader() {
- TestStart();
- THttpRequestHeader httpRequestHeader;
- httpHeaderParser->Init(&httpRequestHeader);
+ TestFinish();
+}
+
+void THttpHeaderParserTestSuite::TestIncorrectRequestHeader() {
+ TestStart();
+ THttpRequestHeader httpRequestHeader;
+ httpHeaderParser->Init(&httpRequestHeader);
const char* request = "GET /search?q=hi HTP/1.1\r\n"
"Host: www.google.ru:8080\r\n\r\n";
- i32 result = httpHeaderParser->Execute(request, strlen(request));
- UNIT_ASSERT(result != 2);
- TestFinish();
-}
-
-void THttpHeaderParserTestSuite::TestLastModified() {
- TestStart();
- THttpHeader h;
- UNIT_ASSERT(0 == httpHeaderParser->Init(&h));
- const char* headers =
- "HTTP/1.1 200 OK\r\n"
- "Content-Type: text/html\r\n"
- "Last-Modified: Thu, 13 Aug 2009 14:27:08 GMT\r\n\r\n";
- UNIT_ASSERT(2 == httpHeaderParser->Execute(headers, strlen(headers)));
- UNIT_ASSERT_VALUES_EQUAL(
+ i32 result = httpHeaderParser->Execute(request, strlen(request));
+ UNIT_ASSERT(result != 2);
+ TestFinish();
+}
+
+void THttpHeaderParserTestSuite::TestLastModified() {
+ TestStart();
+ THttpHeader h;
+ UNIT_ASSERT(0 == httpHeaderParser->Init(&h));
+ const char* headers =
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Type: text/html\r\n"
+ "Last-Modified: Thu, 13 Aug 2009 14:27:08 GMT\r\n\r\n";
+ UNIT_ASSERT(2 == httpHeaderParser->Execute(headers, strlen(headers)));
+ UNIT_ASSERT_VALUES_EQUAL(
TInstant::ParseIso8601Deprecated("2009-08-13 14:27:08Z").TimeT(),
h.http_time);
- TestFinish();
-}
-
-void THttpHeaderParserTestSuite::TestLastModifiedCorrupted() {
- TestStart();
- THttpHeader h;
- UNIT_ASSERT(0 == httpHeaderParser->Init(&h));
- const char* headers =
- "HTTP/1.1 200 OK\r\n"
- "Content-Type: text/html\r\n"
- "Last-Modified: Thu, 13 Aug 2009 14:\r\n\r\n";
- UNIT_ASSERT(2 == httpHeaderParser->Execute(headers, strlen(headers)));
- UNIT_ASSERT(h.http_time < 0); // XXX: don't understand what is the proper value
- TestFinish();
-}
-
+ TestFinish();
+}
+
+void THttpHeaderParserTestSuite::TestLastModifiedCorrupted() {
+ TestStart();
+ THttpHeader h;
+ UNIT_ASSERT(0 == httpHeaderParser->Init(&h));
+ const char* headers =
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Type: text/html\r\n"
+ "Last-Modified: Thu, 13 Aug 2009 14:\r\n\r\n";
+ UNIT_ASSERT(2 == httpHeaderParser->Execute(headers, strlen(headers)));
+ UNIT_ASSERT(h.http_time < 0); // XXX: don't understand what is the proper value
+ TestFinish();
+}
+
void THttpHeaderParserTestSuite::TestXRobotsTagUnknownTags() {
TestStart();
THttpHeader httpHeader;
@@ -424,29 +424,29 @@ void THttpHeaderParserTestSuite::TestRelCanonical() {
TestFinish();
}
-void THttpHeaderParserTestSuite::TestResponseHeaderOnRequest() {
- TestStart();
- THttpHeader httpHeader;
- httpHeaderParser->Init(&httpHeader);
+void THttpHeaderParserTestSuite::TestResponseHeaderOnRequest() {
+ TestStart();
+ THttpHeader httpHeader;
+ httpHeaderParser->Init(&httpHeader);
const char* request = "GET /search?q=hi HTP/1.1\r\n"
"Host: www.google.ru:8080\r\n\r\n";
- i32 result = httpHeaderParser->Execute(request, strlen(request));
+ i32 result = httpHeaderParser->Execute(request, strlen(request));
UNIT_ASSERT_EQUAL(result, -3);
- TestFinish();
-}
-
-void THttpHeaderParserTestSuite::TestRequestHeaderOnResponse() {
- TestStart();
- THttpRequestHeader httpRequestHeader;
- httpHeaderParser->Init(&httpRequestHeader);
+ TestFinish();
+}
+
+void THttpHeaderParserTestSuite::TestRequestHeaderOnResponse() {
+ TestStart();
+ THttpRequestHeader httpRequestHeader;
+ httpHeaderParser->Init(&httpRequestHeader);
const char* response = "HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Last-Modified: Thu, 13 Aug 2009 14:\r\n\r\n";
- i32 result = httpHeaderParser->Execute(response, strlen(response));
+ i32 result = httpHeaderParser->Execute(response, strlen(response));
UNIT_ASSERT_EQUAL(result, -3);
- TestFinish();
-}
-
+ TestFinish();
+}
+
void THttpHeaderParserTestSuite::TestMimeType() {
TestStart();
THttpHeader httpHeader;
@@ -486,8 +486,8 @@ void THttpHeaderParserTestSuite::TestRepeatedContentEncoding() {
TestFinish();
}
-UNIT_TEST_SUITE_REGISTRATION(THttpHeaderParserTestSuite);
-
+UNIT_TEST_SUITE_REGISTRATION(THttpHeaderParserTestSuite);
+
Y_UNIT_TEST_SUITE(TestHttpChunkParser) {
static THttpChunkParser initParser() {
THttpChunkParser parser;