aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http
diff options
context:
space:
mode:
authorAlexander Fokin <apfokin@gmail.com>2022-02-10 16:45:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:38 +0300
commit863a59a65247c24db7cb06789bc5cf79d04da32f (patch)
tree139dc000c8cd4a40f5659e421b7c75135d080307 /library/cpp/http
parentf64e95a9eb9ab03240599eb9581c5a9102426a96 (diff)
downloadydb-863a59a65247c24db7cb06789bc5cf79d04da32f.tar.gz
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http')
-rw-r--r--library/cpp/http/io/chunk.cpp38
-rw-r--r--library/cpp/http/io/chunk_ut.cpp98
-rw-r--r--library/cpp/http/io/stream.cpp30
-rw-r--r--library/cpp/http/server/http_ut.cpp12
4 files changed, 89 insertions, 89 deletions
diff --git a/library/cpp/http/io/chunk.cpp b/library/cpp/http/io/chunk.cpp
index 6975d9eac1..1bdc0fbf49 100644
--- a/library/cpp/http/io/chunk.cpp
+++ b/library/cpp/http/io/chunk.cpp
@@ -65,32 +65,32 @@ public:
}
inline size_t Read(void* buf, size_t len) {
- return Perform(len, [this, buf](size_t toRead) { return Slave_->Read(buf, toRead); });
- }
-
- inline size_t Skip(size_t len) {
- return Perform(len, [this](size_t toSkip) { return Slave_->Skip(toSkip); });
- }
-
-private:
+ return Perform(len, [this, buf](size_t toRead) { return Slave_->Read(buf, toRead); });
+ }
+
+ inline size_t Skip(size_t len) {
+ return Perform(len, [this](size_t toSkip) { return Slave_->Skip(toSkip); });
+ }
+
+private:
template <class Operation>
- inline size_t Perform(size_t len, const Operation& operation) {
+ inline size_t Perform(size_t len, const Operation& operation) {
if (!HavePendingData()) {
return 0;
}
- const size_t toProcess = Min(Pending_, len);
+ const size_t toProcess = Min(Pending_, len);
- if (toProcess) {
- const size_t processed = operation(toProcess);
+ if (toProcess) {
+ const size_t processed = operation(toProcess);
- if (!processed) {
+ if (!processed) {
ythrow yexception() << "malformed http chunk";
}
- Pending_ -= processed;
+ Pending_ -= processed;
- return processed;
+ return processed;
}
return 0;
@@ -154,10 +154,10 @@ size_t TChunkedInput::DoRead(void* buf, size_t len) {
return Impl_->Read(buf, len);
}
-size_t TChunkedInput::DoSkip(size_t len) {
- return Impl_->Skip(len);
-}
-
+size_t TChunkedInput::DoSkip(size_t len) {
+ return Impl_->Skip(len);
+}
+
class TChunkedOutput::TImpl {
typedef IOutputStream::TPart TPart;
diff --git a/library/cpp/http/io/chunk_ut.cpp b/library/cpp/http/io/chunk_ut.cpp
index da283f8568..beaeababd2 100644
--- a/library/cpp/http/io/chunk_ut.cpp
+++ b/library/cpp/http/io/chunk_ut.cpp
@@ -13,50 +13,50 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
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;
- }
-
+ for (size_t pos = 0; pos < s.size(); pos += 2 * chunkSize)
+ result += s.substr(pos, chunkSize);
+ return result;
+ }
+
void WriteTestData(IOutputStream * stream, TString * contents) {
- contents->clear();
- for (size_t i = 0; i < sizeof(test_data); ++i) {
- stream->Write(test_data, i);
- contents->append(test_data, i);
- }
- }
-
+ contents->clear();
+ for (size_t i = 0; i < sizeof(test_data); ++i) {
+ stream->Write(test_data, i);
+ contents->append(test_data, i);
+ }
+ }
+
void ReadInSmallChunks(IInputStream * stream, TString * contents) {
- char buf[11];
- size_t read = 0;
-
- contents->clear();
- do {
- read = stream->Read(buf, sizeof(buf));
- contents->append(buf, read);
- } while (read > 0);
- }
-
+ char buf[11];
+ size_t read = 0;
+
+ contents->clear();
+ do {
+ read = stream->Read(buf, sizeof(buf));
+ contents->append(buf, read);
+ } while (read > 0);
+ }
+
void ReadCombed(IInputStream * stream, TString * contents, size_t chunkSize) {
Y_ASSERT(chunkSize < 128);
- char buf[128];
-
- contents->clear();
- while (true) {
- size_t read = stream->Load(buf, chunkSize);
- contents->append(buf, read);
- if (read == 0)
- break;
-
- size_t toSkip = chunkSize;
- size_t skipped = 0;
- do {
- skipped = stream->Skip(toSkip);
- toSkip -= skipped;
- } while (skipped != 0 && toSkip != 0);
- }
- }
-
+ char buf[128];
+
+ contents->clear();
+ while (true) {
+ size_t read = stream->Load(buf, chunkSize);
+ contents->append(buf, read);
+ if (read == 0)
+ break;
+
+ size_t toSkip = chunkSize;
+ size_t skipped = 0;
+ do {
+ skipped = stream->Skip(toSkip);
+ toSkip -= skipped;
+ } while (skipped != 0 && toSkip != 0);
+ }
+ }
+
Y_UNIT_TEST(TestChunkedIo) {
TTempFile tmpFile(CDATA);
TString tmp;
@@ -64,17 +64,17 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
{
TUnbufferedFileOutput fo(CDATA);
TChunkedOutput co(&fo);
- WriteTestData(&co, &tmp);
- }
+ WriteTestData(&co, &tmp);
+ }
- {
+ {
TUnbufferedFileInput fi(CDATA);
- TChunkedInput ci(&fi);
+ TChunkedInput ci(&fi);
TString r;
- ReadInSmallChunks(&ci, &r);
-
- UNIT_ASSERT_EQUAL(r, tmp);
+ ReadInSmallChunks(&ci, &r);
+
+ UNIT_ASSERT_EQUAL(r, tmp);
}
{
@@ -82,9 +82,9 @@ Y_UNIT_TEST_SUITE(TestChunkedIO) {
TChunkedInput ci(&fi);
TString r;
- ReadCombed(&ci, &r, 11);
+ ReadCombed(&ci, &r, 11);
- UNIT_ASSERT_EQUAL(r, CombString(tmp, 11));
+ UNIT_ASSERT_EQUAL(r, CombString(tmp, 11));
}
}
diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp
index 6689be684f..ebbe460e42 100644
--- a/library/cpp/http/io/stream.cpp
+++ b/library/cpp/http/io/stream.cpp
@@ -161,11 +161,11 @@ public:
}
inline size_t Read(void* buf, size_t len) {
- return Perform(len, [this, buf](size_t toRead) { return Input_->Read(buf, toRead); });
+ return Perform(len, [this, buf](size_t toRead) { return Input_->Read(buf, toRead); });
}
-
- inline size_t Skip(size_t len) {
- return Perform(len, [this](size_t toSkip) { return Input_->Skip(toSkip); });
+
+ inline size_t Skip(size_t len) {
+ return Perform(len, [this](size_t toSkip) { return Input_->Skip(toSkip); });
}
inline const TString& FirstLine() const noexcept {
@@ -210,8 +210,8 @@ public:
private:
template <class Operation>
- inline size_t Perform(size_t len, const Operation& operation) {
- size_t processed = operation(len);
+ inline size_t Perform(size_t len, const Operation& operation) {
+ size_t processed = operation(len);
if (processed == 0 && len > 0) {
if (!ChunkedInput_) {
Trailers_.ConstructInPlace();
@@ -222,11 +222,11 @@ private:
if (ChunkedInput_->Read(&symbol, 1) != 0) {
ythrow THttpParseException() << "some data remaining in TChunkedInput";
}
- }
- }
- return processed;
- }
-
+ }
+ }
+ return processed;
+ }
+
struct TParsedHeaders {
bool Chunked = false;
bool KeepAlive = false;
@@ -403,10 +403,10 @@ size_t THttpInput::DoRead(void* buf, size_t len) {
return Impl_->Read(buf, len);
}
-size_t THttpInput::DoSkip(size_t len) {
- return Impl_->Skip(len);
-}
-
+size_t THttpInput::DoSkip(size_t len) {
+ return Impl_->Skip(len);
+}
+
const THttpHeaders& THttpInput::Headers() const noexcept {
return Impl_->Headers();
}
diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp
index cc62bb988e..d29dbf6f79 100644
--- a/library/cpp/http/server/http_ut.cpp
+++ b/library/cpp/http/server/http_ut.cpp
@@ -234,11 +234,11 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
zlib.Flush();
zlib.Finish();
}
- r << "Content-Length: " << compressedContent.Size() << CrLf;
+ r << "Content-Length: " << compressedContent.Size() << CrLf;
r << CrLf;
s->Send(r.Data(), r.Size());
CheckContinue(si);
- Hdr = r.Str();
+ Hdr = r.Str();
TString tosend = compressedContent.Str();
s->Send(tosend.data(), tosend.size());
} else {
@@ -247,11 +247,11 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
r << CrLf;
s->Send(r.Data(), r.Size());
CheckContinue(si);
- Hdr = r.Str();
+ Hdr = r.Str();
s->Send(Content.data(), Content.size());
} else {
r << CrLf;
- Hdr = r.Str();
+ Hdr = r.Str();
s->Send(r.Data(), r.Size());
}
}
@@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
TStringStream ss;
TransferData(&input, &ss);
- return ss.Str();
+ return ss.Str();
}
TString GetDescription() const {
@@ -271,7 +271,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
if (ContentEncoding.size()) {
ss << " with encoding=" << ContentEncoding;
}
- return ss.Str();
+ return ss.Str();
} else {
return Hdr;
}