aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/server/response.cpp
diff options
context:
space:
mode:
authorishfb <ishfb@yandex-team.ru>2022-02-10 16:48:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:08 +0300
commit069c69f58fd78de3cf2e6eb2304047281e21fb65 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/http/server/response.cpp
parent0170772a2dbf133f32e17ca137ff64790d43831f (diff)
downloadydb-069c69f58fd78de3cf2e6eb2304047281e21fb65.tar.gz
Restoring authorship annotation for <ishfb@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/server/response.cpp')
-rw-r--r--library/cpp/http/server/response.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/library/cpp/http/server/response.cpp b/library/cpp/http/server/response.cpp
index 52d5f28e5b..52d64c91ce 100644
--- a/library/cpp/http/server/response.cpp
+++ b/library/cpp/http/server/response.cpp
@@ -1,65 +1,65 @@
-#include "response.h"
+#include "response.h"
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/stream/mem.h>
#include <util/string/cast.h>
-
-THttpResponse& THttpResponse::AddMultipleHeaders(const THttpHeaders& headers) {
- for (THttpHeaders::TConstIterator i = headers.Begin(); i != headers.End(); ++i) {
- this->Headers.AddHeader(*i);
- }
- return *this;
-}
-
+
+THttpResponse& THttpResponse::AddMultipleHeaders(const THttpHeaders& headers) {
+ for (THttpHeaders::TConstIterator i = headers.Begin(); i != headers.End(); ++i) {
+ this->Headers.AddHeader(*i);
+ }
+ return *this;
+}
+
THttpResponse& THttpResponse::SetContentType(const TStringBuf& contentType) {
Headers.AddOrReplaceHeader(THttpInputHeader("Content-Type", ToString(contentType)));
return *this;
-}
-
+}
+
void THttpResponse::OutTo(IOutputStream& os) const {
TVector<IOutputStream::TPart> parts;
- const size_t FIRST_LINE_PARTS = 3;
+ const size_t FIRST_LINE_PARTS = 3;
const size_t HEADERS_PARTS = Headers.Count() * 4;
- const size_t CONTENT_PARTS = 5;
- parts.reserve(FIRST_LINE_PARTS + HEADERS_PARTS + CONTENT_PARTS);
-
- // first line
+ const size_t CONTENT_PARTS = 5;
+ parts.reserve(FIRST_LINE_PARTS + HEADERS_PARTS + CONTENT_PARTS);
+
+ // first line
parts.push_back(IOutputStream::TPart(TStringBuf("HTTP/1.1 ")));
parts.push_back(IOutputStream::TPart(HttpCodeStrEx(Code)));
parts.push_back(IOutputStream::TPart::CrLf());
-
- // headers
+
+ // headers
for (THttpHeaders::TConstIterator i = Headers.Begin(); i != Headers.End(); ++i) {
parts.push_back(IOutputStream::TPart(i->Name()));
parts.push_back(IOutputStream::TPart(TStringBuf(": ")));
parts.push_back(IOutputStream::TPart(i->Value()));
parts.push_back(IOutputStream::TPart::CrLf());
- }
-
+ }
+
char buf[50];
if (!Content.empty()) {
TMemoryOutput mo(buf, sizeof(buf));
-
+
mo << Content.size();
parts.push_back(IOutputStream::TPart(TStringBuf("Content-Length: ")));
parts.push_back(IOutputStream::TPart(buf, mo.Buf() - buf));
parts.push_back(IOutputStream::TPart::CrLf());
- }
-
- // content
+ }
+
+ // content
parts.push_back(IOutputStream::TPart::CrLf());
if (!Content.empty()) {
parts.push_back(IOutputStream::TPart(Content));
- }
-
+ }
+
os.Write(parts.data(), parts.size());
}
template <>
void Out<THttpResponse>(IOutputStream& os, const THttpResponse& resp) {
resp.OutTo(os);
-}
+}