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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#pragma once
#include "service.h"
#include <util/stream/output.h>
namespace NMonitoring {
class TMonService2;
class IMonPage;
// XXX: IHttpRequest is already taken
struct IMonHttpRequest {
virtual ~IMonHttpRequest();
virtual IOutputStream& Output() = 0;
virtual HTTP_METHOD GetMethod() const = 0;
virtual TStringBuf GetPath() const = 0;
virtual TStringBuf GetPathInfo() const = 0;
virtual TStringBuf GetUri() const = 0;
virtual const TCgiParameters& GetParams() const = 0;
virtual const TCgiParameters& GetPostParams() const = 0;
virtual TStringBuf GetPostContent() const = 0;
virtual const THttpHeaders& GetHeaders() const = 0;
virtual TStringBuf GetHeader(TStringBuf name) const = 0;
virtual TStringBuf GetCookie(TStringBuf name) const = 0;
virtual TString GetRemoteAddr() const = 0;
virtual TString GetServiceTitle() const = 0;
virtual IMonPage* GetPage() const = 0;
virtual IMonHttpRequest* MakeChild(IMonPage* page, const TString& pathInfo) const = 0;
};
struct TMonService2HttpRequest: IMonHttpRequest {
IOutputStream* const Out;
const IHttpRequest* const HttpRequest;
TMonService2* const MonService;
IMonPage* const MonPage;
const TString PathInfo;
TMonService2HttpRequest* const Parent;
TMonService2HttpRequest(
IOutputStream* out, const IHttpRequest* httpRequest,
TMonService2* monService, IMonPage* monPage,
const TString& pathInfo,
TMonService2HttpRequest* parent)
: Out(out)
, HttpRequest(httpRequest)
, MonService(monService)
, MonPage(monPage)
, PathInfo(pathInfo)
, Parent(parent)
{
}
~TMonService2HttpRequest() override;
IOutputStream& Output() override;
HTTP_METHOD GetMethod() const override;
TStringBuf GetPath() const override;
TStringBuf GetPathInfo() const override;
TStringBuf GetUri() const override;
const TCgiParameters& GetParams() const override;
const TCgiParameters& GetPostParams() const override;
TStringBuf GetPostContent() const override {
return HttpRequest->GetPostContent();
}
TStringBuf GetHeader(TStringBuf name) const override;
TStringBuf GetCookie(TStringBuf name) const override;
const THttpHeaders& GetHeaders() const override;
TString GetRemoteAddr() const override;
IMonPage* GetPage() const override {
return MonPage;
}
TMonService2HttpRequest* MakeChild(IMonPage* page, const TString& pathInfo) const override {
return new TMonService2HttpRequest{
Out, HttpRequest, MonService, page,
pathInfo, const_cast<TMonService2HttpRequest*>(this)
};
}
TString GetServiceTitle() const override;
};
}
|