aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http
diff options
context:
space:
mode:
authoragri <agri@yandex-team.ru>2022-02-10 16:48:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:12 +0300
commit2909866fbc652492b7d7cab3023cb19489dc4fd8 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/http
parentd3530b2692e400bd4d29bd4f07cafaee139164e7 (diff)
downloadydb-2909866fbc652492b7d7cab3023cb19489dc4fd8.tar.gz
Restoring authorship annotation for <agri@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http')
-rw-r--r--library/cpp/http/io/stream.cpp52
-rw-r--r--library/cpp/http/io/stream.h8
-rw-r--r--library/cpp/http/server/http.cpp14
-rw-r--r--library/cpp/http/server/http.h8
-rw-r--r--library/cpp/http/server/http_ex.cpp52
-rw-r--r--library/cpp/http/server/http_ut.cpp72
6 files changed, 103 insertions, 103 deletions
diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp
index 083a531b31..6689be684f 100644
--- a/library/cpp/http/io/stream.cpp
+++ b/library/cpp/http/io/stream.cpp
@@ -145,7 +145,7 @@ public:
, HasContentLength_(false)
, ContentLength_(0)
, ContentEncoded_(false)
- , Expect100Continue_(false)
+ , Expect100Continue_(false)
{
BuildInputChain();
Y_ASSERT(Input_);
@@ -204,10 +204,10 @@ public:
return HasContentLength_ || ChunkedInput_;
}
- inline bool HasExpect100Continue() const noexcept {
- return Expect100Continue_;
- }
-
+ inline bool HasExpect100Continue() const noexcept {
+ return Expect100Continue_;
+ }
+
private:
template <class Operation>
inline size_t Perform(size_t len, const Operation& operation) {
@@ -324,14 +324,14 @@ private:
}
}
[[fallthrough]];
- HEADERCMP(header, "expect") {
- auto findContinue = [&](const TStringBuf& s) {
+ HEADERCMP(header, "expect") {
+ auto findContinue = [&](const TStringBuf& s) {
if (strnicmp(s.data(), "100-continue", 13) == 0) {
- Expect100Continue_ = true;
- }
- };
- ForEach(header.Value(), findContinue);
- }
+ Expect100Continue_ = true;
+ }
+ };
+ ForEach(header.Value(), findContinue);
+ }
break;
}
}
@@ -386,7 +386,7 @@ private:
ui64 ContentLength_;
bool ContentEncoded_;
- bool Expect100Continue_;
+ bool Expect100Continue_;
};
THttpInput::THttpInput(IInputStream* slave)
@@ -452,10 +452,10 @@ bool THttpInput::HasContent() const noexcept {
return Impl_->HasContent();
}
-bool THttpInput::HasExpect100Continue() const noexcept {
- return Impl_->HasExpect100Continue();
-}
-
+bool THttpInput::HasExpect100Continue() const noexcept {
+ return Impl_->HasExpect100Continue();
+}
+
class THttpOutput::TImpl {
class TSizeCalculator: public IOutputStream {
public:
@@ -512,11 +512,11 @@ public:
inline ~TImpl() {
}
- inline void SendContinue() {
- Output_->Write("HTTP/1.1 100 Continue\r\n\r\n");
- Output_->Flush();
- }
-
+ inline void SendContinue() {
+ Output_->Write("HTTP/1.1 100 Continue\r\n\r\n");
+ Output_->Flush();
+ }
+
inline void Write(const void* buf, size_t len) {
if (Finished_) {
ythrow THttpException() << "can not write to finished stream";
@@ -954,10 +954,10 @@ bool THttpOutput::CanBeKeepAlive() const noexcept {
return Impl_->CanBeKeepAlive();
}
-void THttpOutput::SendContinue() {
- Impl_->SendContinue();
-}
-
+void THttpOutput::SendContinue() {
+ Impl_->SendContinue();
+}
+
const TString& THttpOutput::FirstLine() const noexcept {
return Impl_->FirstLine();
}
diff --git a/library/cpp/http/io/stream.h b/library/cpp/http/io/stream.h
index e0846ef107..78ca4fc814 100644
--- a/library/cpp/http/io/stream.h
+++ b/library/cpp/http/io/stream.h
@@ -84,8 +84,8 @@ public:
/// Returns true if Content-Length or Transfer-Encoding header received
bool HasContent() const noexcept;
- bool HasExpect100Continue() const noexcept;
-
+ bool HasExpect100Continue() const noexcept;
+
private:
size_t DoRead(void* buf, size_t len) override;
size_t DoSkip(size_t len) override;
@@ -145,8 +145,8 @@ public:
/// не завершается после окончания транзакции.
bool CanBeKeepAlive() const noexcept;
- void SendContinue();
-
+ void SendContinue();
+
/*
* first line - response or request
*/
diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp
index a1b70f10e1..128583bdd7 100644
--- a/library/cpp/http/server/http.cpp
+++ b/library/cpp/http/server/http.cpp
@@ -67,7 +67,7 @@ public:
THttpServer::TImpl* HttpServ_ = nullptr;
bool Reject_ = false;
TInstant LastUsed;
- TInstant AcceptMoment;
+ TInstant AcceptMoment;
size_t ReceivedRequests = 0;
};
@@ -300,7 +300,7 @@ public:
~TListenSocket() override {
}
- void OnPollEvent(TInstant) override {
+ void OnPollEvent(TInstant) override {
SOCKET s = ::accept(S_, nullptr, nullptr);
if (s == INVALID_SOCKET) {
@@ -589,7 +589,7 @@ void TClientConnection::OnPollEvent(TInstant now) {
}
THolder<TClientRequest> obj(HttpServ_->CreateRequest(this_));
- AcceptMoment = now;
+ AcceptMoment = now;
HttpServ_->AddRequest(obj, Reject_);
}
@@ -776,10 +776,10 @@ NAddr::IRemoteAddrRef TClientRequest::GetListenerSockAddrRef() const noexcept {
return Conn_->ListenerSockAddrRef_;
}
-TInstant TClientRequest::AcceptMoment() const noexcept {
- return Conn_->AcceptMoment;
-}
-
+TInstant TClientRequest::AcceptMoment() const noexcept {
+ return Conn_->AcceptMoment;
+}
+
/*
* TRequestReplier
*/
diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h
index 0b1607bfbb..b292d38f27 100644
--- a/library/cpp/http/server/http.h
+++ b/library/cpp/http/server/http.h
@@ -8,7 +8,7 @@
#include <util/memory/blob.h>
#include <util/generic/ptr.h>
#include <util/generic/vector.h>
-#include <util/system/atomic.h>
+#include <util/system/atomic.h>
class IThreadFactory;
class TClientRequest;
@@ -90,8 +90,8 @@ public:
const IThreadPool& GetRequestQueue() const;
const IThreadPool& GetFailQueue() const;
- static TAtomicBase AcceptReturnsInvalidSocketCounter();
-
+ static TAtomicBase AcceptReturnsInvalidSocketCounter();
+
private:
bool MaxRequestsReached() const;
@@ -120,7 +120,7 @@ public:
THttpServer* HttpServ() const noexcept;
const TSocket& Socket() const noexcept;
NAddr::IRemoteAddrRef GetListenerSockAddrRef() const noexcept;
- TInstant AcceptMoment() const noexcept;
+ TInstant AcceptMoment() const noexcept;
bool IsLocal() const;
bool CheckLoopback();
diff --git a/library/cpp/http/server/http_ex.cpp b/library/cpp/http/server/http_ex.cpp
index 7fb6378482..e07db22bfc 100644
--- a/library/cpp/http/server/http_ex.cpp
+++ b/library/cpp/http/server/http_ex.cpp
@@ -27,45 +27,45 @@ bool THttpClientRequestExtension::ProcessHeaders(TBaseServerRequestData& rd, TBl
char* s = RequestString.begin();
- enum EMethod {
- NotImplemented,
- Get,
- Post,
- Put,
+ enum EMethod {
+ NotImplemented,
+ Get,
+ Post,
+ Put,
Patch,
Delete,
- };
-
- enum EMethod foundMethod;
- char* urlStart;
-
+ };
+
+ enum EMethod foundMethod;
+ char* urlStart;
+
if (strnicmp(s, "GET ", 4) == 0) {
- foundMethod = Get;
- urlStart = s + 4;
- } else if (strnicmp(s, "POST ", 5) == 0) {
- foundMethod = Post;
- urlStart = s + 5;
- } else if (strnicmp(s, "PUT ", 4) == 0) {
- foundMethod = Put;
- urlStart = s + 4;
+ foundMethod = Get;
+ urlStart = s + 4;
+ } else if (strnicmp(s, "POST ", 5) == 0) {
+ foundMethod = Post;
+ urlStart = s + 5;
+ } else if (strnicmp(s, "PUT ", 4) == 0) {
+ foundMethod = Put;
+ urlStart = s + 4;
} else if (strnicmp(s, "PATCH ", 6) == 0) {
foundMethod = Patch;
urlStart = s + 6;
} else if (strnicmp(s, "DELETE ", 7) == 0) {
foundMethod = Delete;
urlStart = s + 7;
- } else {
- foundMethod = NotImplemented;
- }
-
- switch (foundMethod) {
+ } else {
+ foundMethod = NotImplemented;
+ }
+
+ switch (foundMethod) {
case Get:
case Delete:
if (!Parse(urlStart, rd)) {
return false;
}
break;
-
+
case Post:
case Put:
case Patch:
@@ -91,8 +91,8 @@ bool THttpClientRequestExtension::ProcessHeaders(TBaseServerRequestData& rd, TBl
} catch (...) {
Output() << "HTTP/1.1 400 Bad request\r\n\r\n";
return false;
- }
-
+ }
+
if (!Parse(urlStart, rd)) {
return false;
}
diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp
index 4e0e6bd69d..cc62bb988e 100644
--- a/library/cpp/http/server/http_ut.cpp
+++ b/library/cpp/http/server/http_ut.cpp
@@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
};
static const TString CrLf = "\r\n";
-
+
struct TTestRequest {
TTestRequest(ui16 port, TString content = TString())
: Port(port)
@@ -145,23 +145,23 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
{
}
- void CheckContinue(TSocketInput& si) {
- if (Expect100Continue) {
- TStringStream ss;
+ void CheckContinue(TSocketInput& si) {
+ if (Expect100Continue) {
+ TStringStream ss;
TString firstLine;
- si.ReadLine(firstLine);
- for (;;) {
+ si.ReadLine(firstLine);
+ for (;;) {
TString buf;
- si.ReadLine(buf);
+ si.ReadLine(buf);
if (buf.size() == 0) {
- break;
- }
- ss << buf << CrLf;
- }
- UNIT_ASSERT_EQUAL(firstLine, "HTTP/1.1 100 Continue");
- }
- }
-
+ break;
+ }
+ ss << buf << CrLf;
+ }
+ UNIT_ASSERT_EQUAL(firstLine, "HTTP/1.1 100 Continue");
+ }
+ }
+
TString Execute() {
TSocket* s = nullptr;
THolder<TSocket> singleReqSocket;
@@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
s = singleReqSocket.Get();
}
bool isPost = Type == "POST";
- TSocketInput si(*s);
+ TSocketInput si(*s);
if (UseHttpOutput) {
TSocketOutput so(*s);
@@ -194,21 +194,21 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
} else {
r << "Transfer-Encoding: chunked" << CrLf;
}
- if (Expect100Continue) {
- r << "Expect: 100-continue" << CrLf;
- }
+ if (Expect100Continue) {
+ r << "Expect: 100-continue" << CrLf;
+ }
}
r << CrLf;
if (isPost) {
- output.Write(r.Str());
- output.Flush();
- CheckContinue(si);
- output.Write(Content);
- output.Finish();
- } else {
- output.Write(r.Str());
- output.Finish();
+ output.Write(r.Str());
+ output.Flush();
+ CheckContinue(si);
+ output.Write(Content);
+ output.Finish();
+ } else {
+ output.Write(r.Str());
+ output.Finish();
}
} else {
TStringStream r;
@@ -222,9 +222,9 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
if (EnableResponseEncoding) {
r << "Accept-Encoding: gzip, deflate, x-gzip, x-deflate, y-lzo, y-lzf, y-lzq, y-bzip2, y-lzma" << CrLf;
}
- if (isPost && Expect100Continue) {
- r << "Expect: 100-continue" << CrLf;
- }
+ if (isPost && Expect100Continue) {
+ r << "Expect: 100-continue" << CrLf;
+ }
if (isPost && ContentEncoding.size() && Content.size()) {
r << "Content-Encoding: " << ContentEncoding << CrLf;
TStringStream compressedContent;
@@ -237,7 +237,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
r << "Content-Length: " << compressedContent.Size() << CrLf;
r << CrLf;
s->Send(r.Data(), r.Size());
- CheckContinue(si);
+ CheckContinue(si);
Hdr = r.Str();
TString tosend = compressedContent.Str();
s->Send(tosend.data(), tosend.size());
@@ -246,7 +246,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
r << "Content-Length: " << Content.size() << CrLf;
r << CrLf;
s->Send(r.Data(), r.Size());
- CheckContinue(si);
+ CheckContinue(si);
Hdr = r.Str();
s->Send(Content.data(), Content.size());
} else {
@@ -286,7 +286,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
THolder<TSocket> KeepAlivedSocket;
bool EnableResponseEncoding = false;
TString Hdr;
- bool Expect100Continue = false;
+ bool Expect100Continue = false;
};
class TFailingMtpQueue: public TSimpleThreadPool {
@@ -354,10 +354,10 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
r.ContentEncoding = encoder;
for (bool expect100Continue : trueFalse) {
- r.Expect100Continue = expect100Continue;
+ r.Expect100Continue = expect100Continue;
TString resp = r.Execute();
- UNIT_ASSERT_C(resp == res, "diff echo response for request:\n" + r.GetDescription());
- }
+ UNIT_ASSERT_C(resp == res, "diff echo response for request:\n" + r.GetDescription());
+ }
}
}
}