blob: 5ce6d3ddc6c948f0c7a0d94b93ce8aca1be8472f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "parsed_request.h"
#include <util/string/strip.h>
#include <util/generic/yexception.h>
#include <util/string/cast.h>
static TStringBuf StripLeft(const TStringBuf s Y_LIFETIME_BOUND) noexcept {
auto b = s.begin();
auto e = s.end();
StripRangeBegin(b, e);
return TStringBuf(b, e);
}
TParsedHttpRequest::TParsedHttpRequest(const TStringBuf str Y_LIFETIME_BOUND) {
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 Y_LIFETIME_BOUND) {
req.Split('?', Path, Cgi);
}
|