aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/io
diff options
context:
space:
mode:
authorVlad Yaroslavlev <vladon@vladon.com>2022-02-10 16:46:23 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:23 +0300
commit706b83ed7de5a473436620367af31fc0ceecde07 (patch)
tree103305d30dec77e8f6367753367f59b3cd68f9f1 /library/cpp/http/io
parent918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff)
downloadydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http/io')
-rw-r--r--library/cpp/http/io/chunk.cpp14
-rw-r--r--library/cpp/http/io/chunk.h4
-rw-r--r--library/cpp/http/io/chunk_ut.cpp18
-rw-r--r--library/cpp/http/io/headers.cpp8
-rw-r--r--library/cpp/http/io/headers.h22
-rw-r--r--library/cpp/http/io/headers_ut.cpp12
-rw-r--r--library/cpp/http/io/stream.cpp92
-rw-r--r--library/cpp/http/io/stream.h28
-rw-r--r--library/cpp/http/io/stream_ut.cpp56
9 files changed, 127 insertions, 127 deletions
diff --git a/library/cpp/http/io/chunk.cpp b/library/cpp/http/io/chunk.cpp
index 6975d9eac1..181a6cec11 100644
--- a/library/cpp/http/io/chunk.cpp
+++ b/library/cpp/http/io/chunk.cpp
@@ -6,14 +6,14 @@
#include <util/generic/utility.h>
#include <util/generic/yexception.h>
-static inline size_t ParseHex(const TString& s) {
+static inline size_t ParseHex(const TString& s) {
if (s.empty()) {
ythrow yexception() << "can not parse chunk length(empty string)";
}
size_t ret = 0;
- for (TString::const_iterator c = s.begin(); c != s.end(); ++c) {
+ for (TString::const_iterator c = s.begin(); c != s.end(); ++c) {
const char ch = *c;
if (ch >= '0' && ch <= '9') {
@@ -61,7 +61,7 @@ public:
}
}
- inline ~TImpl() {
+ inline ~TImpl() {
}
inline size_t Read(void* buf, size_t len) {
@@ -111,7 +111,7 @@ private:
}
inline bool ProceedToNextChunk() {
- TString len(Slave_->ReadLine());
+ TString len(Slave_->ReadLine());
if (len.empty()) {
/*
@@ -147,7 +147,7 @@ TChunkedInput::TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers
{
}
-TChunkedInput::~TChunkedInput() {
+TChunkedInput::~TChunkedInput() {
}
size_t TChunkedInput::DoRead(void* buf, size_t len) {
@@ -167,7 +167,7 @@ public:
{
}
- inline ~TImpl() {
+ inline ~TImpl() {
}
inline void Write(const void* buf, size_t len) {
@@ -217,7 +217,7 @@ TChunkedOutput::TChunkedOutput(IOutputStream* slave)
{
}
-TChunkedOutput::~TChunkedOutput() {
+TChunkedOutput::~TChunkedOutput() {
try {
Finish();
} catch (...) {
diff --git a/library/cpp/http/io/chunk.h b/library/cpp/http/io/chunk.h
index 88d89fafda..d73cbf1523 100644
--- a/library/cpp/http/io/chunk.h
+++ b/library/cpp/http/io/chunk.h
@@ -16,7 +16,7 @@ public:
/// Если передан указатель на trailers, то туда будут записаны HTTP trailer'ы (возможно пустые),
/// которые идут после чанков.
TChunkedInput(IInputStream* slave, TMaybe<THttpHeaders>* trailers = nullptr);
- ~TChunkedInput() override;
+ ~TChunkedInput() override;
private:
size_t DoRead(void* buf, size_t len) override;
@@ -33,7 +33,7 @@ private:
class TChunkedOutput: public IOutputStream {
public:
TChunkedOutput(IOutputStream* slave);
- ~TChunkedOutput() override;
+ ~TChunkedOutput() override;
private:
void DoWrite(const void* buf, size_t len) override;
diff --git a/library/cpp/http/io/chunk_ut.cpp b/library/cpp/http/io/chunk_ut.cpp
index da283f8568..2fb65a92f5 100644
--- a/library/cpp/http/io/chunk_ut.cpp
+++ b/library/cpp/http/io/chunk_ut.cpp
@@ -11,8 +11,8 @@
Y_UNIT_TEST_SUITE(TestChunkedIO) {
static const char test_data[] = "87s6cfbsudg cuisg s igasidftasiy tfrcua6s";
- TString CombString(const TString& s, size_t chunkSize) {
- TString result;
+ TString CombString(const TString& s, size_t chunkSize) {
+ TString result;
for (size_t pos = 0; pos < s.size(); pos += 2 * chunkSize)
result += s.substr(pos, chunkSize);
return result;
@@ -59,18 +59,18 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
Y_UNIT_TEST(TestChunkedIo) {
TTempFile tmpFile(CDATA);
- TString tmp;
+ TString tmp;
{
- TUnbufferedFileOutput fo(CDATA);
+ TUnbufferedFileOutput fo(CDATA);
TChunkedOutput co(&fo);
WriteTestData(&co, &tmp);
}
{
- TUnbufferedFileInput fi(CDATA);
+ TUnbufferedFileInput fi(CDATA);
TChunkedInput ci(&fi);
- TString r;
+ TString r;
ReadInSmallChunks(&ci, &r);
@@ -78,9 +78,9 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
}
{
- TUnbufferedFileInput fi(CDATA);
+ TUnbufferedFileInput fi(CDATA);
TChunkedInput ci(&fi);
- TString r;
+ TString r;
ReadCombed(&ci, &r, 11);
@@ -92,7 +92,7 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
bool hasError = false;
try {
- TString badChunk = "10\r\nqwerty";
+ TString badChunk = "10\r\nqwerty";
TMemoryInput mi(badChunk.data(), badChunk.size());
TChunkedInput ci(&mi);
TransferData(&ci, &Cnull);
diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp
index 4ec27a29e8..3647828946 100644
--- a/library/cpp/http/io/headers.cpp
+++ b/library/cpp/http/io/headers.cpp
@@ -8,14 +8,14 @@
#include <util/string/cast.h>
#include <util/string/strip.h>
-static inline TStringBuf Trim(const char* b, const char* e) noexcept {
+static inline TStringBuf Trim(const char* b, const char* e) noexcept {
return StripString(TStringBuf(b, e));
}
THttpInputHeader::THttpInputHeader(const TStringBuf header) {
size_t pos = header.find(':');
- if (pos == TString::npos) {
+ if (pos == TString::npos) {
ythrow THttpParseException() << "can not parse http header(" << TString{header}.Quote() << ")";
}
@@ -43,8 +43,8 @@ void THttpInputHeader::OutTo(IOutputStream* stream) const {
}
THttpHeaders::THttpHeaders(IInputStream* stream) {
- TString header;
- TString line;
+ TString header;
+ TString line;
bool rdOk = stream->ReadLine(header);
while (rdOk && !header.empty()) {
diff --git a/library/cpp/http/io/headers.h b/library/cpp/http/io/headers.h
index a71793d1c6..139aab2f81 100644
--- a/library/cpp/http/io/headers.h
+++ b/library/cpp/http/io/headers.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/deque.h>
#include <util/generic/vector.h>
@@ -21,12 +21,12 @@ public:
THttpInputHeader(TString name, TString value);
/// Возвращает имя параметра.
- inline const TString& Name() const noexcept {
+ inline const TString& Name() const noexcept {
return Name_;
}
/// Возвращает значение параметра.
- inline const TString& Value() const noexcept {
+ inline const TString& Value() const noexcept {
return Value_;
}
@@ -34,13 +34,13 @@ public:
void OutTo(IOutputStream* stream) const;
/// Возвращает строку "имя параметра: значение".
- inline TString ToString() const {
+ inline TString ToString() const {
return Name_ + TStringBuf(": ") + Value_;
}
private:
- TString Name_;
- TString Value_;
+ TString Name_;
+ TString Value_;
};
/// Контейнер для хранения HTTP-заголовков
@@ -56,7 +56,7 @@ public:
THttpHeaders(IInputStream* stream);
/// Стандартный итератор.
- inline TConstIterator Begin() const noexcept {
+ inline TConstIterator Begin() const noexcept {
return Headers_.begin();
}
inline TConstIterator begin() const noexcept {
@@ -64,7 +64,7 @@ public:
}
/// Стандартный итератор.
- inline TConstIterator End() const noexcept {
+ inline TConstIterator End() const noexcept {
return Headers_.end();
}
inline TConstIterator end() const noexcept {
@@ -72,12 +72,12 @@ public:
}
/// Возвращает количество заголовков в контейнере.
- inline size_t Count() const noexcept {
+ inline size_t Count() const noexcept {
return Headers_.size();
}
/// Проверяет, содержит ли контейнер хотя бы один заголовок.
- inline bool Empty() const noexcept {
+ inline bool Empty() const noexcept {
return Headers_.empty();
}
@@ -114,7 +114,7 @@ public:
void OutTo(IOutputStream* stream) const;
/// Обменивает наборы заголовков двух контейнеров.
- void Swap(THttpHeaders& headers) noexcept {
+ void Swap(THttpHeaders& headers) noexcept {
Headers_.swap(headers.Headers_);
}
diff --git a/library/cpp/http/io/headers_ut.cpp b/library/cpp/http/io/headers_ut.cpp
index 1d23ef8fdc..12c45b3b7f 100644
--- a/library/cpp/http/io/headers_ut.cpp
+++ b/library/cpp/http/io/headers_ut.cpp
@@ -1,5 +1,5 @@
#include <util/generic/set.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <utility>
@@ -21,7 +21,7 @@ namespace {
public:
void Add(TStringBuf name, TStringBuf value) {
- Impl.emplace(TString(name), TString(value));
+ Impl.emplace(TString(name), TString(value));
}
bool operator==(const THeadersExistence& rhs) const {
@@ -29,7 +29,7 @@ namespace {
}
private:
- typedef TMultiSet<std::pair<TString, TString>> TImpl;
+ typedef TMultiSet<std::pair<TString, TString>> TImpl;
TImpl Impl;
};
}
@@ -66,11 +66,11 @@ public:
private:
static void AddHeaderImpl1Arg(THttpHeaders& headers, TStringBuf name, TStringBuf value) {
- headers.AddHeader(THttpInputHeader(TString(name), TString(value)));
+ headers.AddHeader(THttpInputHeader(TString(name), TString(value)));
}
static void AddHeaderImpl2Args(THttpHeaders& headers, TStringBuf name, TStringBuf value) {
- headers.AddHeader(TString(name), TString(value));
+ headers.AddHeader(TString(name), TString(value));
}
static void AddOrReplaceHeaderImpl1Arg(THttpHeaders& headers, TStringBuf name, TStringBuf value) {
@@ -154,7 +154,7 @@ void THttpHeadersTest::DoTestAddOrReplaceOperation(TAddHeaderFunction addHeader,
void THttpHeadersTest::TestAddHeaderTemplateness() {
THttpHeaders h1;
h1.AddHeader("h1", "v1");
- h1.AddHeader("h2", TString("v2"));
+ h1.AddHeader("h2", TString("v2"));
h1.AddHeader("h3", TStringBuf("v3"));
h1.AddHeader("h4", TStringBuf("v4"));
diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp
index 6689be684f..25859087c3 100644
--- a/library/cpp/http/io/stream.cpp
+++ b/library/cpp/http/io/stream.cpp
@@ -17,7 +17,7 @@
#include <util/string/cast.h>
#include <util/string/strip.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/utility.h>
#include <util/generic/hash_set.h>
#include <util/generic/yexception.h>
@@ -131,7 +131,7 @@ namespace {
}
class THttpInput::TImpl {
- typedef THashSet<TString> TAcceptCodings;
+ typedef THashSet<TString> TAcceptCodings;
public:
inline TImpl(IInputStream* slave)
@@ -157,7 +157,7 @@ public:
return s;
}
- inline ~TImpl() {
+ inline ~TImpl() {
}
inline size_t Read(void* buf, size_t len) {
@@ -168,11 +168,11 @@ public:
return Perform(len, [this](size_t toSkip) { return Input_->Skip(toSkip); });
}
- inline const TString& FirstLine() const noexcept {
+ inline const TString& FirstLine() const noexcept {
return FirstLine_;
}
- inline const THttpHeaders& Headers() const noexcept {
+ inline const THttpHeaders& Headers() const noexcept {
return Headers_;
}
@@ -180,15 +180,15 @@ public:
return Trailers_;
}
- inline bool IsKeepAlive() const noexcept {
+ inline bool IsKeepAlive() const noexcept {
return KeepAlive_;
}
- inline bool AcceptEncoding(const TString& s) const {
+ inline bool AcceptEncoding(const TString& s) const {
return Codings_.find(to_lower(s)) != Codings_.end();
}
- inline bool GetContentLength(ui64& value) const noexcept {
+ inline bool GetContentLength(ui64& value) const noexcept {
if (HasContentLength_) {
value = ContentLength_;
return true;
@@ -196,7 +196,7 @@ public:
return false;
}
- inline bool ContentEncoded() const noexcept {
+ inline bool ContentEncoded() const noexcept {
return ContentEncoded_;
}
@@ -252,7 +252,7 @@ private:
};
template <class Functor>
- inline void ForEach(TString in, Functor& f) {
+ inline void ForEach(TString in, Functor& f) {
in.to_lower();
const char* b = in.begin();
@@ -287,7 +287,7 @@ private:
size_t pos = FirstLine_.rfind(' ');
// In HTTP/1.1 Keep-Alive is turned on by default
- if (pos != TString::npos && strcmp(FirstLine_.c_str() + pos + 1, "HTTP/1.1") == 0) {
+ if (pos != TString::npos && strcmp(FirstLine_.c_str() + pos + 1, "HTTP/1.1") == 0) {
p.KeepAlive = true; //request
} else if (strnicmp(FirstLine_.data(), "HTTP/1.1", 8) == 0) {
p.KeepAlive = true; //reply
@@ -375,7 +375,7 @@ private:
*/
IInputStream* Input_;
- TString FirstLine_;
+ TString FirstLine_;
THttpHeaders Headers_;
TMaybe<THttpHeaders> Trailers_;
bool KeepAlive_;
@@ -396,7 +396,7 @@ THttpInput::THttpInput(IInputStream* slave)
THttpInput::THttpInput(THttpInput&& httpInput) = default;
-THttpInput::~THttpInput() {
+THttpInput::~THttpInput() {
}
size_t THttpInput::DoRead(void* buf, size_t len) {
@@ -407,7 +407,7 @@ size_t THttpInput::DoSkip(size_t len) {
return Impl_->Skip(len);
}
-const THttpHeaders& THttpInput::Headers() const noexcept {
+const THttpHeaders& THttpInput::Headers() const noexcept {
return Impl_->Headers();
}
@@ -415,15 +415,15 @@ const TMaybe<THttpHeaders>& THttpInput::Trailers() const noexcept {
return Impl_->Trailers();
}
-const TString& THttpInput::FirstLine() const noexcept {
+const TString& THttpInput::FirstLine() const noexcept {
return Impl_->FirstLine();
}
-bool THttpInput::IsKeepAlive() const noexcept {
+bool THttpInput::IsKeepAlive() const noexcept {
return Impl_->IsKeepAlive();
}
-bool THttpInput::AcceptEncoding(const TString& coding) const {
+bool THttpInput::AcceptEncoding(const TString& coding) const {
return Impl_->AcceptEncoding(coding);
}
@@ -440,11 +440,11 @@ TString THttpInput::BestCompressionScheme() const {
return BestCompressionScheme(TCompressionCodecFactory::Instance().GetBestCodecs());
}
-bool THttpInput::GetContentLength(ui64& value) const noexcept {
+bool THttpInput::GetContentLength(ui64& value) const noexcept {
return Impl_->GetContentLength(value);
}
-bool THttpInput::ContentEncoded() const noexcept {
+bool THttpInput::ContentEncoded() const noexcept {
return Impl_->ContentEncoded();
}
@@ -459,17 +459,17 @@ bool THttpInput::HasExpect100Continue() const noexcept {
class THttpOutput::TImpl {
class TSizeCalculator: public IOutputStream {
public:
- inline TSizeCalculator() noexcept {
+ inline TSizeCalculator() noexcept {
}
- ~TSizeCalculator() override {
+ ~TSizeCalculator() override {
}
void DoWrite(const void* /*buf*/, size_t len) override {
Length_ += len;
}
- inline size_t Length() const noexcept {
+ inline size_t Length() const noexcept {
return Length_;
}
@@ -509,7 +509,7 @@ public:
{
}
- inline ~TImpl() {
+ inline ~TImpl() {
}
inline void SendContinue() {
@@ -579,7 +579,7 @@ public:
Finished_ = true;
}
- inline const THttpHeaders& SentHeaders() const noexcept {
+ inline const THttpHeaders& SentHeaders() const noexcept {
return Headers_;
}
@@ -599,11 +599,11 @@ public:
CompressionHeaderEnabled_ = enable;
}
- inline bool IsCompressionEnabled() const noexcept {
+ inline bool IsCompressionEnabled() const noexcept {
return !ComprSchemas_.empty();
}
- inline bool IsKeepAliveEnabled() const noexcept {
+ inline bool IsKeepAliveEnabled() const noexcept {
return KeepAliveEnabled_;
}
@@ -615,7 +615,7 @@ public:
return CompressionHeaderEnabled_;
}
- inline bool CanBeKeepAlive() const noexcept {
+ inline bool CanBeKeepAlive() const noexcept {
return SupportChunkedTransfer() && IsKeepAliveEnabled() && (Request_ ? Request_->IsKeepAlive() : true);
}
@@ -628,15 +628,15 @@ public:
}
private:
- static inline bool IsResponse(const TString& s) noexcept {
+ static inline bool IsResponse(const TString& s) noexcept {
return strnicmp(s.data(), "HTTP/", 5) == 0;
}
- static inline bool IsRequest(const TString& s) noexcept {
+ static inline bool IsRequest(const TString& s) noexcept {
return !IsResponse(s);
}
- inline bool IsHttpRequest() const noexcept {
+ inline bool IsHttpRequest() const noexcept {
return IsRequest(FirstLine_);
}
@@ -651,16 +651,16 @@ private:
return false;
}
- inline bool IsHttpResponse() const noexcept {
+ inline bool IsHttpResponse() const noexcept {
return IsResponse(FirstLine_);
}
- inline bool HasRequestBody() const noexcept {
+ inline bool HasRequestBody() const noexcept {
return strnicmp(FirstLine_.data(), "POST", 4) == 0 ||
strnicmp(FirstLine_.data(), "PATCH", 5) == 0 ||
strnicmp(FirstLine_.data(), "PUT", 3) == 0;
}
- static inline size_t ParseHttpVersion(const TString& s) {
+ static inline size_t ParseHttpVersion(const TString& s) {
if (s.empty()) {
ythrow THttpParseException() << "malformed http stream";
}
@@ -709,7 +709,7 @@ private:
Version_ = parsed_version;
}
- inline void Process(const TString& s) {
+ inline void Process(const TString& s) {
Y_ASSERT(State_ != HeadersSent);
if (State_ == Begin) {
@@ -760,7 +760,7 @@ private:
}
}
- inline bool SupportChunkedTransfer() const noexcept {
+ inline bool SupportChunkedTransfer() const noexcept {
return Version_ >= 1100;
}
@@ -791,8 +791,8 @@ private:
}
}
- inline TString BuildAcceptEncoding() const {
- TString ret;
+ inline TString BuildAcceptEncoding() const {
+ TString ret;
for (const auto& coding : ComprSchemas_) {
if (ret) {
@@ -813,7 +813,7 @@ private:
for (THttpHeaders::TConstIterator h = Headers_.Begin(); h != Headers_.End(); ++h) {
const THttpInputHeader& header = *h;
- const TString hl = to_lower(header.Name());
+ const TString hl = to_lower(header.Name());
if (hl == TStringBuf("connection")) {
keepAlive = to_lower(header.Value()) == TStringBuf("keep-alive");
@@ -850,7 +850,7 @@ private:
Headers_.AddOrReplaceHeader(hdr);
}
- inline void RemoveHeader(const TString& hdr) {
+ inline void RemoveHeader(const TString& hdr) {
Headers_.RemoveHeader(hdr);
}
@@ -859,8 +859,8 @@ private:
TState State_;
IOutputStream* Output_;
TStreams<IOutputStream, 8> Streams_;
- TString Line_;
- TString FirstLine_;
+ TString Line_;
+ TString FirstLine_;
THttpHeaders Headers_;
THttpInput* Request_;
size_t Version_;
@@ -886,7 +886,7 @@ THttpOutput::THttpOutput(IOutputStream* slave, THttpInput* request)
{
}
-THttpOutput::~THttpOutput() {
+THttpOutput::~THttpOutput() {
try {
Finish();
} catch (...) {
@@ -905,7 +905,7 @@ void THttpOutput::DoFinish() {
Impl_->Finish();
}
-const THttpHeaders& THttpOutput::SentHeaders() const noexcept {
+const THttpHeaders& THttpOutput::SentHeaders() const noexcept {
return Impl_->SentHeaders();
}
@@ -934,7 +934,7 @@ void THttpOutput::EnableCompressionHeader(bool enable) {
Impl_->EnableCompressionHeader(enable);
}
-bool THttpOutput::IsKeepAliveEnabled() const noexcept {
+bool THttpOutput::IsKeepAliveEnabled() const noexcept {
return Impl_->IsKeepAliveEnabled();
}
@@ -942,7 +942,7 @@ bool THttpOutput::IsBodyEncodingEnabled() const noexcept {
return Impl_->IsBodyEncodingEnabled();
}
-bool THttpOutput::IsCompressionEnabled() const noexcept {
+bool THttpOutput::IsCompressionEnabled() const noexcept {
return Impl_->IsCompressionEnabled();
}
@@ -950,7 +950,7 @@ bool THttpOutput::IsCompressionHeaderEnabled() const noexcept {
return Impl_->IsCompressionHeaderEnabled();
}
-bool THttpOutput::CanBeKeepAlive() const noexcept {
+bool THttpOutput::CanBeKeepAlive() const noexcept {
return Impl_->CanBeKeepAlive();
}
diff --git a/library/cpp/http/io/stream.h b/library/cpp/http/io/stream.h
index 78ca4fc814..1ad69a0329 100644
--- a/library/cpp/http/io/stream.h
+++ b/library/cpp/http/io/stream.h
@@ -5,7 +5,7 @@
#include <util/stream/output.h>
#include <util/generic/maybe.h>
#include <util/generic/ptr.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/yexception.h>
#include <util/generic/array_ref.h>
@@ -26,13 +26,13 @@ class THttpInput: public IInputStream {
public:
THttpInput(IInputStream* slave);
THttpInput(THttpInput&& httpInput);
- ~THttpInput() override;
+ ~THttpInput() override;
/*
* parsed http headers
*/
/// Возвращает контейнер с заголовками ответа HTTP-сервера.
- const THttpHeaders& Headers() const noexcept;
+ const THttpHeaders& Headers() const noexcept;
/*
* parsed http trailers
@@ -49,7 +49,7 @@ public:
/// Возвращает первую строку ответа HTTP-сервера.
/// @details Первая строка HTTP-сервера - строка состояния,
/// содержащая три поля: версию HTTP, код состояния и описание.
- const TString& FirstLine() const noexcept;
+ const TString& FirstLine() const noexcept;
/*
* connection can be keep-alive
@@ -57,29 +57,29 @@ public:
/// Проверяет, не завершено ли соединение с сервером.
/// @details Транзакция считается завершенной, если не передан заголовок
/// "Connection: Keep Alive".
- bool IsKeepAlive() const noexcept;
+ bool IsKeepAlive() const noexcept;
/*
* output data can be encoded
*/
/// Проверяет, поддерживается ли данный тип кодирования содержимого
/// ответа HTTP-сервера.
- bool AcceptEncoding(const TString& coding) const;
+ bool AcceptEncoding(const TString& coding) const;
/// Пытается определить наилучший тип кодирования ответа HTTP-сервера.
/// @details Если ответ сервера говорит о том, что поддерживаются
/// любые типы кодирования, выбирается gzip. В противном случае
/// из списка типов кодирования выбирается лучший из поддерживаемых сервером.
- TString BestCompressionScheme() const;
+ TString BestCompressionScheme() const;
TString BestCompressionScheme(TArrayRef<const TStringBuf> codings) const;
/// Если заголовки содержат Content-Length, возвращает true и
/// записывает значение из заголовка в value
- bool GetContentLength(ui64& value) const noexcept;
+ bool GetContentLength(ui64& value) const noexcept;
/// Признак запакованности данных, - если выставлен, то Content-Length, при наличии в заголовках,
/// показывает объём запакованных данных, а из THttpInput мы будем вычитывать уже распакованные.
- bool ContentEncoded() const noexcept;
+ bool ContentEncoded() const noexcept;
/// Returns true if Content-Length or Transfer-Encoding header received
bool HasContent() const noexcept;
@@ -100,13 +100,13 @@ class THttpOutput: public IOutputStream {
public:
THttpOutput(IOutputStream* slave);
THttpOutput(IOutputStream* slave, THttpInput* request);
- ~THttpOutput() override;
+ ~THttpOutput() override;
/*
* sent http headers
*/
/// Возвращает контейнер с заголовками запроса к HTTP-серверу.
- const THttpHeaders& SentHeaders() const noexcept;
+ const THttpHeaders& SentHeaders() const noexcept;
/// Устанавливает режим, при котором сервер выдает ответ в упакованном виде.
void EnableCompression(bool enable);
@@ -125,10 +125,10 @@ public:
void EnableCompressionHeader(bool enable);
/// Проверяет, производится ли выдача ответов в упакованном виде.
- bool IsCompressionEnabled() const noexcept;
+ bool IsCompressionEnabled() const noexcept;
/// Проверяет, не завершается ли соединение с сервером после окончания транзакции.
- bool IsKeepAliveEnabled() const noexcept;
+ bool IsKeepAliveEnabled() const noexcept;
/// Проверяет, преобразуется ли тело HTTP-запроса/ответа в соответствии
/// с заголовками Content-Encoding и Transfer-Encoding
@@ -143,7 +143,7 @@ public:
*/
/// Проверяет, можно ли установить режим, при котором соединение с сервером
/// не завершается после окончания транзакции.
- bool CanBeKeepAlive() const noexcept;
+ bool CanBeKeepAlive() const noexcept;
void SendContinue();
diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp
index 1ea35df675..c67d6ce48c 100644
--- a/library/cpp/http/io/stream_ut.cpp
+++ b/library/cpp/http/io/stream_ut.cpp
@@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
};
public:
- inline TTestHttpServer(const TString& res)
+ inline TTestHttpServer(const TString& res)
: Res_(res)
{
}
@@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
private:
- TString Res_;
+ TString Res_;
size_t LastRequestSentSize_ = 0;
};
@@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
Y_UNIT_TEST(TestHttpInput) {
- TString res = "I'm a teapot";
+ TString res = "I'm a teapot";
TPortManager pm;
const ui16 port = pm.GetPort();
@@ -106,7 +106,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
output.EnableKeepAlive(true);
output.EnableCompression(true);
- TString r;
+ TString r;
r += "GET / HTTP/1.1";
r += "\r\n";
r += "Host: yandex.lo";
@@ -180,56 +180,56 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
Y_UNIT_TEST(TestKeepAlive) {
{
- TString s = "GET / HTTP/1.0\r\n\r\n";
+ TString s = "GET / HTTP/1.0\r\n\r\n";
TStringInput si(s);
THttpInput in(&si);
UNIT_ASSERT(!in.IsKeepAlive());
}
{
- TString s = "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n";
+ TString s = "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n";
TStringInput si(s);
THttpInput in(&si);
UNIT_ASSERT(in.IsKeepAlive());
}
{
- TString s = "GET / HTTP/1.1\r\n\r\n";
+ TString s = "GET / HTTP/1.1\r\n\r\n";
TStringInput si(s);
THttpInput in(&si);
UNIT_ASSERT(in.IsKeepAlive());
}
{
- TString s = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n";
+ TString s = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n";
TStringInput si(s);
THttpInput in(&si);
UNIT_ASSERT(!in.IsKeepAlive());
}
{
- TString s = "HTTP/1.0 200 Ok\r\n\r\n";
+ TString s = "HTTP/1.0 200 Ok\r\n\r\n";
TStringInput si(s);
THttpInput in(&si);
UNIT_ASSERT(!in.IsKeepAlive());
}
{
- TString s = "HTTP/1.0 200 Ok\r\nConnection: keep-alive\r\n\r\n";
+ TString s = "HTTP/1.0 200 Ok\r\nConnection: keep-alive\r\n\r\n";
TStringInput si(s);
THttpInput in(&si);
UNIT_ASSERT(in.IsKeepAlive());
}
{
- TString s = "HTTP/1.1 200 Ok\r\n\r\n";
+ TString s = "HTTP/1.1 200 Ok\r\n\r\n";
TStringInput si(s);
THttpInput in(&si);
UNIT_ASSERT(in.IsKeepAlive());
}
{
- TString s = "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n";
+ TString s = "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n";
TStringInput si(s);
THttpInput in(&si);
UNIT_ASSERT(!in.IsKeepAlive());
@@ -237,7 +237,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
Y_UNIT_TEST(TestMinRequest) {
- TString res = "qqqqqq";
+ TString res = "qqqqqq";
TPortManager pm;
const ui16 port = pm.GetPort();
@@ -263,7 +263,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
Y_UNIT_TEST(TestResponseWithBlanks) {
- TString res = "qqqqqq\r\n\r\nsdasdsad\r\n";
+ TString res = "qqqqqq\r\n\r\nsdasdsad\r\n";
TPortManager pm;
const ui16 port = pm.GetPort();
@@ -282,13 +282,13 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
THttpInput input(&si);
unsigned httpCode = ParseHttpRetCode(input.FirstLine());
UNIT_ASSERT_VALUES_EQUAL(httpCode, 200u);
- TString reply = input.ReadAll();
+ TString reply = input.ReadAll();
UNIT_ASSERT_VALUES_EQUAL(reply, res);
server.Stop();
}
Y_UNIT_TEST(TestOutputFlush) {
- TString str;
+ TString str;
TStringOutput strOut(str);
TBufferedOutput bufOut(&strOut, 8192);
THttpOutput httpOut(&bufOut);
@@ -308,8 +308,8 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
Y_UNIT_TEST(TestOutputPostFlush) {
- TString str;
- TString checkStr;
+ TString str;
+ TString checkStr;
TStringOutput strOut(str);
TStringOutput checkOut(checkStr);
TBufferedOutput bufOut(&strOut, 8192);
@@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
TString MakeHttpOutputBody(const char* body, bool encodingEnabled) {
- TString str;
+ TString str;
TStringOutput strOut(str);
{
TBufferedOutput bufOut(&strOut, 8192);
@@ -353,7 +353,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
const char* bodyDelimiter = "\r\n\r\n";
size_t bodyPos = str.find(bodyDelimiter);
- UNIT_ASSERT(bodyPos != TString::npos);
+ UNIT_ASSERT(bodyPos != TString::npos);
return str.substr(bodyPos + strlen(bodyDelimiter));
};
@@ -373,7 +373,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
Y_UNIT_TEST(TestOutputFinish) {
- TString str;
+ TString str;
TStringOutput strOut(str);
TBufferedOutput bufOut(&strOut, 8192);
THttpOutput httpOut(&bufOut);
@@ -399,8 +399,8 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
const char* headerLine3 = "\tAccept-Language";
const char* headerLine4 = "Content-Length: 18";
- TString endLine("\r\n");
- TString r;
+ TString endLine("\r\n");
+ TString r;
r += headerLine0 + endLine;
r += headerLine1 + endLine;
r += headerLine2 + endLine;
@@ -414,15 +414,15 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
UNIT_ASSERT_VALUES_EQUAL(httpHeaders.Count(), 3u);
THttpHeaders::TConstIterator it = httpHeaders.Begin();
- UNIT_ASSERT_VALUES_EQUAL(it->ToString(), TString(headerLine1));
- UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString::Join(headerLine2, headerLine3));
- UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString(headerLine4));
+ UNIT_ASSERT_VALUES_EQUAL(it->ToString(), TString(headerLine1));
+ UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString::Join(headerLine2, headerLine3));
+ UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString(headerLine4));
}
Y_UNIT_TEST(ContentLengthRemoval) {
TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n");
THttpInput i(&request);
- TString result;
+ TString result;
TStringOutput out(result);
THttpOutput httpOut(&out, &i);
@@ -661,7 +661,7 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
out << "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n";
out << "";
out.Finish();
- TString result = outBuf.Str();
+ TString result = outBuf.Str();
UNIT_ASSERT(!result.Contains(TStringBuf("0\r\n")));
}