diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/http/misc/parsed_request.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/http/misc/parsed_request.cpp')
-rw-r--r-- | library/cpp/http/misc/parsed_request.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/library/cpp/http/misc/parsed_request.cpp b/library/cpp/http/misc/parsed_request.cpp new file mode 100644 index 0000000000..e332a24e91 --- /dev/null +++ b/library/cpp/http/misc/parsed_request.cpp @@ -0,0 +1,32 @@ +#include "parsed_request.h" + +#include <util/string/strip.h> +#include <util/generic/yexception.h> +#include <util/string/cast.h> + +static inline TStringBuf StripLeft(const TStringBuf& s) noexcept { + const char* b = s.begin(); + const char* e = s.end(); + + StripRangeBegin(b, e); + + return TStringBuf(b, e); +} + +TParsedHttpRequest::TParsedHttpRequest(const TStringBuf& str) { + TStringBuf tmp; + + if (!StripLeft(str).TrySplit(' ', Method, tmp)) { + ythrow yexception() << "bad request(" << ToString(str).Quote() << ")"; + } + + if (!StripLeft(tmp).TrySplit(' ', Request, Proto)) { + ythrow yexception() << "bad request(" << ToString(str).Quote() << ")"; + } + + Proto = StripLeft(Proto); +} + +TParsedHttpLocation::TParsedHttpLocation(const TStringBuf& req) { + req.Split('?', Path, Cgi); +} |