diff options
author | vmordovin <vmordovin@yandex-team.ru> | 2022-02-10 16:48:14 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:14 +0300 |
commit | 6a1e535429145ec1ecfbc5f1efd3c95323261fb5 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/http/io/stream_ut.cpp | |
parent | 7c7f9bbcf57e15838d15afa94b31d8254b5d7776 (diff) | |
download | ydb-6a1e535429145ec1ecfbc5f1efd3c95323261fb5.tar.gz |
Restoring authorship annotation for <vmordovin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/io/stream_ut.cpp')
-rw-r--r-- | library/cpp/http/io/stream_ut.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 9737467bfc..1ea35df675 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -1,5 +1,5 @@ #include "stream.h" -#include "chunk.h" +#include "chunk.h" #include <library/cpp/http/server/http_ex.h> @@ -331,23 +331,23 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { httpOut.Flush(); UNIT_ASSERT_VALUES_EQUAL(checkStr.size(), str.size()); } - + TString MakeHttpOutputBody(const char* body, bool encodingEnabled) { TString str; TStringOutput strOut(str); { TBufferedOutput bufOut(&strOut, 8192); THttpOutput httpOut(&bufOut); - + httpOut.EnableKeepAlive(true); httpOut.EnableCompression(true); httpOut.EnableBodyEncoding(encodingEnabled); - + httpOut << "POST / HTTP/1.1\r\n"; httpOut << "Host: yandex.ru\r\n"; httpOut << "Content-Encoding: gzip\r\n"; httpOut << "\r\n"; - + UNIT_ASSERT_VALUES_EQUAL(str.size(), 0u); httpOut << body; } @@ -376,29 +376,29 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { TString str; TStringOutput strOut(str); TBufferedOutput bufOut(&strOut, 8192); - THttpOutput httpOut(&bufOut); - - httpOut.EnableKeepAlive(true); - httpOut.EnableCompression(true); - + THttpOutput httpOut(&bufOut); + + httpOut.EnableKeepAlive(true); + httpOut.EnableCompression(true); + const char* header = "GET / HTTP/1.1\r\nHost: yandex.ru\r\n\r\n"; httpOut << header; - + unsigned curLen = str.size(); const char* body = "<html>Hello</html>"; - httpOut << body; + httpOut << body; UNIT_ASSERT_VALUES_EQUAL(curLen, str.size()); httpOut.Finish(); UNIT_ASSERT_VALUES_EQUAL(curLen + strlen(body), str.size()); - } - + } + Y_UNIT_TEST(TestMultilineHeaders) { const char* headerLine0 = "HTTP/1.1 200 OK"; const char* headerLine1 = "Content-Language: en"; const char* headerLine2 = "Vary: Accept-Encoding, "; const char* headerLine3 = "\tAccept-Language"; const char* headerLine4 = "Content-Length: 18"; - + TString endLine("\r\n"); TString r; r += headerLine0 + endLine; @@ -564,53 +564,53 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), "GGLOL"); } } - + Y_UNIT_TEST(TestInputHasContent) { - { - TStringStream request; + { + TStringStream request; request << "POST / HTTP/1.1\r\n" "Host: yandex.ru\r\n" "\r\n"; - request << "HTTPDATA"; - - TStringInput input(request.Str()); - THttpInput httpInput(&input); - - UNIT_ASSERT(!httpInput.HasContent()); - UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), ""); - } - - { - TStringStream request; + request << "HTTPDATA"; + + TStringInput input(request.Str()); + THttpInput httpInput(&input); + + UNIT_ASSERT(!httpInput.HasContent()); + UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), ""); + } + + { + TStringStream request; request << "POST / HTTP/1.1\r\n" "Host: yandex.ru\r\n" "Content-Length: 8" "\r\n\r\n"; - request << "HTTPDATA"; - - TStringInput input(request.Str()); - THttpInput httpInput(&input); - - UNIT_ASSERT(httpInput.HasContent()); - UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), "HTTPDATA"); - } - - { - TStringStream request; + request << "HTTPDATA"; + + TStringInput input(request.Str()); + THttpInput httpInput(&input); + + UNIT_ASSERT(httpInput.HasContent()); + UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), "HTTPDATA"); + } + + { + TStringStream request; request << "POST / HTTP/1.1\r\n" "Host: yandex.ru\r\n" "Transfer-Encoding: chunked" "\r\n\r\n"; - request << "8\r\nHTTPDATA\r\n0\r\n"; - - TStringInput input(request.Str()); - THttpInput httpInput(&input); - - UNIT_ASSERT(httpInput.HasContent()); - UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), "HTTPDATA"); - } - } - + request << "8\r\nHTTPDATA\r\n0\r\n"; + + TStringInput input(request.Str()); + THttpInput httpInput(&input); + + UNIT_ASSERT(httpInput.HasContent()); + UNIT_ASSERT_VALUES_EQUAL(httpInput.ReadAll(), "HTTPDATA"); + } + } + Y_UNIT_TEST(TestHttpInputHeadRequest) { class THeadOnlyInput: public IInputStream { public: |