diff options
author | ishfb <ishfb@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
commit | 069c69f58fd78de3cf2e6eb2304047281e21fb65 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/http/server/response.h | |
parent | 0170772a2dbf133f32e17ca137ff64790d43831f (diff) | |
download | ydb-069c69f58fd78de3cf2e6eb2304047281e21fb65.tar.gz |
Restoring authorship annotation for <ishfb@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/server/response.h')
-rw-r--r-- | library/cpp/http/server/response.h | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/http/server/response.h b/library/cpp/http/server/response.h index 20751e9096..a75cb85605 100644 --- a/library/cpp/http/server/response.h +++ b/library/cpp/http/server/response.h @@ -1,69 +1,69 @@ -#pragma once +#pragma once #include <library/cpp/http/misc/httpcodes.h> #include <library/cpp/http/io/stream.h> -#include <util/generic/strbuf.h> -#include <util/string/cast.h> - -class THttpHeaders; +#include <util/generic/strbuf.h> +#include <util/string/cast.h> + +class THttpHeaders; class IOutputStream; - -class THttpResponse { -public: + +class THttpResponse { +public: THttpResponse() noexcept : Code(HTTP_OK) { } explicit THttpResponse(HttpCodes code) noexcept - : Code(code) - { - } - + : Code(code) + { + } + template <typename ValueType> THttpResponse& AddHeader(const TString& name, const ValueType& value) { - return AddHeader(THttpInputHeader(name, ToString(value))); - } - - THttpResponse& AddHeader(const THttpInputHeader& header) { - Headers.AddHeader(header); - - return *this; - } - - THttpResponse& AddMultipleHeaders(const THttpHeaders& headers); - + return AddHeader(THttpInputHeader(name, ToString(value))); + } + + THttpResponse& AddHeader(const THttpInputHeader& header) { + Headers.AddHeader(header); + + return *this; + } + + THttpResponse& AddMultipleHeaders(const THttpHeaders& headers); + const THttpHeaders& GetHeaders() const { return Headers; } THttpResponse& SetContentType(const TStringBuf& contentType); - /** - * @note If @arg content isn't empty its size is automatically added as a + /** + * @note If @arg content isn't empty its size is automatically added as a * "Content-Length" header during output to IOutputStream. * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) - */ + */ THttpResponse& SetContent(const TString& content) { - Content = content; + Content = content; + + return *this; + } - return *this; - } - TString GetContent() const { return Content; } - /** - * @note If @arg content isn't empty its size is automatically added as a + /** + * @note If @arg content isn't empty its size is automatically added as a * "Content-Length" header during output to IOutputStream. * @see IOutputStream& operator << (IOutputStream&, const THttpResponse&) - */ + */ THttpResponse& SetContent(const TString& content, const TStringBuf& contentType) { return SetContent(content).SetContentType(contentType); } - + HttpCodes HttpCode() const { return Code; } @@ -75,8 +75,8 @@ public: void OutTo(IOutputStream& out) const; -private: - HttpCodes Code; - THttpHeaders Headers; +private: + HttpCodes Code; + THttpHeaders Headers; TString Content; -}; +}; |