blob: 7f322ce0eaab8e5d7649ec9d03d43b5880355284 (
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 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);
}
|