]>
Commit | Line | Data |
---|---|---|
fdc96a39 | 1 | /* |
b510f3a1 | 2 | * DEBUG: section 93 eCAP Interface |
fdc96a39 AR |
3 | */ |
4 | ||
7b67e5b6 AR |
5 | #ifndef SQUID__ECAP__MESSAGE_REP_H |
6 | #define SQUID__ECAP__MESSAGE_REP_H | |
fdc96a39 AR |
7 | |
8 | #include "adaptation/forward.h" | |
1f3c65fc | 9 | #include "adaptation/Message.h" |
555aedbf | 10 | #include "anyp/ProtocolType.h" |
602d9612 A |
11 | #include "BodyPipe.h" |
12 | #include "HttpHeader.h" | |
fdc96a39 | 13 | #include <libecap/common/message.h> |
cf331c99 AR |
14 | #include <libecap/common/header.h> |
15 | #include <libecap/common/body.h> | |
fdc96a39 | 16 | |
1f3c65fc AR |
17 | class HttpMsg; |
18 | class HttpRequest; | |
19 | class HttpReply; | |
20 | ||
af6a12ee AJ |
21 | namespace Adaptation |
22 | { | |
e1381638 AJ |
23 | namespace Ecap |
24 | { | |
fdc96a39 | 25 | |
cf331c99 AR |
26 | class XactionRep; |
27 | ||
28 | // Translates Squid HttpMsg into libecap::Header. | |
29 | class HeaderRep: public libecap::Header | |
30 | { | |
31 | public: | |
32 | typedef libecap::Name Name; | |
33 | typedef libecap::Area Area; | |
34 | ||
35 | public: | |
36 | HeaderRep(HttpMsg &aMessage); | |
37 | ||
8442a9b2 | 38 | /* libecap::Header API */ |
cf331c99 AR |
39 | virtual bool hasAny(const Name &name) const; |
40 | virtual Value value(const Name &name) const; | |
cf331c99 AR |
41 | virtual void add(const Name &name, const Value &value); |
42 | virtual void removeAny(const Name &name); | |
12a410c3 | 43 | virtual void visitEach(libecap::NamedValueVisitor &visitor) const; |
cf331c99 AR |
44 | virtual Area image() const; |
45 | virtual void parse(const Area &buf); // throws on failures | |
46 | ||
cf331c99 AR |
47 | protected: |
48 | static http_hdr_type TranslateHeaderId(const Name &name); | |
cf331c99 AR |
49 | |
50 | private: | |
51 | HttpHeader &theHeader; // the header being translated to libecap | |
52 | HttpMsg &theMessage; // the message being translated to libecap | |
53 | }; | |
54 | ||
77773405 AR |
55 | // Helps translate Squid HttpMsg into libecap::FirstLine (see children). |
56 | class FirstLineRep | |
cf331c99 AR |
57 | { |
58 | public: | |
77773405 AR |
59 | typedef libecap::Name Name; |
60 | ||
61 | public: | |
62 | FirstLineRep(HttpMsg &aMessage); | |
63 | ||
64 | libecap::Version version() const; | |
65 | void version(const libecap::Version &aVersion); | |
66 | Name protocol() const; | |
67 | void protocol(const Name &aProtocol); | |
68 | ||
69 | protected: | |
555aedbf | 70 | static AnyP::ProtocolType TranslateProtocolId(const Name &name); |
77773405 AR |
71 | |
72 | private: | |
73 | HttpMsg &theMessage; // the message which first line is being translated | |
74 | }; | |
75 | ||
76 | // Translates Squid HttpRequest into libecap::RequestLine. | |
77 | class RequestLineRep: public libecap::RequestLine, public FirstLineRep | |
78 | { | |
79 | public: | |
80 | // typedef libecap::Name Name; | |
81 | typedef libecap::Area Area; | |
82 | ||
83 | public: | |
84 | RequestLineRep(HttpRequest &aMessage); | |
cf331c99 | 85 | |
8442a9b2 | 86 | /* libecap::RequestLine API */ |
cf331c99 AR |
87 | virtual void uri(const Area &aUri); |
88 | virtual Area uri() const; | |
cf331c99 AR |
89 | virtual void method(const Name &aMethod); |
90 | virtual Name method() const; | |
77773405 AR |
91 | virtual libecap::Version version() const; |
92 | virtual void version(const libecap::Version &aVersion); | |
93 | virtual Name protocol() const; | |
94 | virtual void protocol(const Name &aProtocol); | |
95 | ||
cf331c99 AR |
96 | private: |
97 | HttpRequest &theMessage; // the request header being translated to libecap | |
98 | }; | |
99 | ||
77773405 AR |
100 | // Translates Squid HttpReply into libecap::StatusLine. |
101 | class StatusLineRep: public libecap::StatusLine, public FirstLineRep | |
cf331c99 AR |
102 | { |
103 | public: | |
77773405 AR |
104 | typedef libecap::Name Name; |
105 | typedef libecap::Area Area; | |
106 | ||
107 | public: | |
108 | StatusLineRep(HttpReply &aMessage); | |
cf331c99 | 109 | |
8442a9b2 | 110 | /* libecap::StatusLine API */ |
cf331c99 AR |
111 | virtual void statusCode(int code); |
112 | virtual int statusCode() const; | |
cf331c99 AR |
113 | virtual void reasonPhrase(const Area &phrase); |
114 | virtual Area reasonPhrase() const; | |
77773405 AR |
115 | virtual libecap::Version version() const; |
116 | virtual void version(const libecap::Version &aVersion); | |
117 | virtual Name protocol() const; | |
118 | virtual void protocol(const Name &aProtocol); | |
119 | ||
cf331c99 AR |
120 | private: |
121 | HttpReply &theMessage; // the request header being translated to libecap | |
122 | }; | |
123 | ||
77773405 | 124 | // Translates Squid BodyPipe into libecap::Body. |
cf331c99 AR |
125 | class BodyRep: public libecap::Body |
126 | { | |
127 | public: | |
cf331c99 AR |
128 | typedef libecap::BodySize BodySize; |
129 | ||
130 | public: | |
77773405 | 131 | BodyRep(const BodyPipe::Pointer &aBody); // using NULL pointer? see tie() |
cf331c99 | 132 | |
77773405 AR |
133 | void tie(const BodyPipe::Pointer &aBody); // late binding if !theBody; |
134 | ||
135 | // libecap::Body API | |
cf331c99 | 136 | virtual BodySize bodySize() const; |
cf331c99 AR |
137 | |
138 | private: | |
139 | BodyPipe::Pointer theBody; // the body being translated to libecap | |
140 | }; | |
141 | ||
fdc96a39 | 142 | // Translates Squid Adaptation::Message into libecap::Message. |
7b67e5b6 | 143 | class MessageRep: public libecap::Message |
fdc96a39 | 144 | { |
fdc96a39 | 145 | public: |
77773405 | 146 | explicit MessageRep(HttpMsg *rawHeader); |
cf331c99 AR |
147 | virtual ~MessageRep(); |
148 | ||
8442a9b2 | 149 | /* libecap::Message API */ |
f1a768b2 | 150 | virtual libecap::shared_ptr<libecap::Message> clone() const; |
f1a768b2 AR |
151 | virtual libecap::FirstLine &firstLine(); |
152 | virtual const libecap::FirstLine &firstLine() const; | |
cf331c99 AR |
153 | virtual libecap::Header &header(); |
154 | virtual const libecap::Header &header() const; | |
cf331c99 AR |
155 | virtual void addBody(); |
156 | virtual libecap::Body *body(); | |
157 | virtual const libecap::Body *body() const; | |
8442a9b2 | 158 | |
f1a768b2 | 159 | void tieBody(Ecap::XactionRep *x); // to a specific transaction |
77773405 | 160 | |
f1a768b2 AR |
161 | Adaptation::Message &raw() { return theMessage; } // for host access |
162 | const Adaptation::Message &raw() const { return theMessage; } // for host | |
fdc96a39 AR |
163 | |
164 | private: | |
77773405 AR |
165 | Adaptation::Message theMessage; // the message being translated to libecap |
166 | libecap::FirstLine *theFirstLineRep; // request or status line wrapper | |
167 | HeaderRep *theHeaderRep; // header wrapper | |
168 | BodyRep *theBodyRep; // body wrapper | |
fdc96a39 AR |
169 | }; |
170 | ||
574b508c AR |
171 | } // namespace Ecap |
172 | } // namespace Adaptation | |
fdc96a39 | 173 | |
7b67e5b6 | 174 | #endif /* SQUID__E_CAP__MESSAGE_REP_H */ |