]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/ecap/MessageRep.h
6 #ifndef SQUID__ECAP__MESSAGE_REP_H
7 #define SQUID__ECAP__MESSAGE_REP_H
10 #include "HttpHeader.h"
12 #include "adaptation/forward.h"
13 #include "adaptation/Message.h"
14 #include <libecap/common/message.h>
15 #include <libecap/common/header.h>
16 #include <libecap/common/body.h>
28 // Translates Squid HttpMsg into libecap::Header.
29 class HeaderRep
: public libecap::Header
32 typedef libecap::Name Name
;
33 typedef libecap::Area Area
;
36 HeaderRep(HttpMsg
&aMessage
);
38 virtual bool hasAny(const Name
&name
) const;
39 virtual Value
value(const Name
&name
) const;
41 virtual void add(const Name
&name
, const Value
&value
);
42 virtual void removeAny(const Name
&name
);
44 virtual Area
image() const;
45 virtual void parse(const Area
&buf
); // throws on failures
48 static http_hdr_type
TranslateHeaderId(const Name
&name
);
51 HttpHeader
&theHeader
; // the header being translated to libecap
52 HttpMsg
&theMessage
; // the message being translated to libecap
56 // Helps translate Squid HttpMsg into libecap::FirstLine (see children).
60 typedef libecap::Name Name
;
63 FirstLineRep(HttpMsg
&aMessage
);
65 libecap::Version
version() const;
66 void version(const libecap::Version
&aVersion
);
67 Name
protocol() const;
68 void protocol(const Name
&aProtocol
);
71 static protocol_t
TranslateProtocolId(const Name
&name
);
74 HttpMsg
&theMessage
; // the message which first line is being translated
77 // Translates Squid HttpRequest into libecap::RequestLine.
78 class RequestLineRep
: public libecap::RequestLine
, public FirstLineRep
81 // typedef libecap::Name Name;
82 typedef libecap::Area Area
;
85 RequestLineRep(HttpRequest
&aMessage
);
87 virtual void uri(const Area
&aUri
);
88 virtual Area
uri() const;
90 virtual void method(const Name
&aMethod
);
91 virtual Name
method() const;
93 virtual libecap::Version
version() const;
94 virtual void version(const libecap::Version
&aVersion
);
95 virtual Name
protocol() const;
96 virtual void protocol(const Name
&aProtocol
);
99 HttpRequest
&theMessage
; // the request header being translated to libecap
102 // Translates Squid HttpReply into libecap::StatusLine.
103 class StatusLineRep
: public libecap::StatusLine
, public FirstLineRep
106 typedef libecap::Name Name
;
107 typedef libecap::Area Area
;
110 StatusLineRep(HttpReply
&aMessage
);
112 virtual void statusCode(int code
);
113 virtual int statusCode() const;
115 virtual void reasonPhrase(const Area
&phrase
);
116 virtual Area
reasonPhrase() const;
118 virtual libecap::Version
version() const;
119 virtual void version(const libecap::Version
&aVersion
);
120 virtual Name
protocol() const;
121 virtual void protocol(const Name
&aProtocol
);
124 HttpReply
&theMessage
; // the request header being translated to libecap
128 // Translates Squid BodyPipe into libecap::Body.
129 class BodyRep
: public libecap::Body
132 typedef libecap::BodySize BodySize
;
135 BodyRep(const BodyPipe::Pointer
&aBody
); // using NULL pointer? see tie()
137 void tie(const BodyPipe::Pointer
&aBody
); // late binding if !theBody;
140 virtual BodySize
bodySize() const;
143 BodyPipe::Pointer theBody
; // the body being translated to libecap
146 // Translates Squid Adaptation::Message into libecap::Message.
147 class MessageRep
: public libecap::Message
150 explicit MessageRep(HttpMsg
*rawHeader
);
151 virtual ~MessageRep();
153 virtual libecap::shared_ptr
<libecap::Message
> clone() const;
155 virtual libecap::FirstLine
&firstLine();
156 virtual const libecap::FirstLine
&firstLine() const;
158 virtual libecap::Header
&header();
159 virtual const libecap::Header
&header() const;
161 virtual void addBody();
162 virtual libecap::Body
*body();
163 virtual const libecap::Body
*body() const;
164 void tieBody(Ecap::XactionRep
*x
); // to a specific transaction
166 Adaptation::Message
&raw() { return theMessage
; } // for host access
167 const Adaptation::Message
&raw() const { return theMessage
; } // for host
170 Adaptation::Message theMessage
; // the message being translated to libecap
171 libecap::FirstLine
*theFirstLineRep
; // request or status line wrapper
172 HeaderRep
*theHeaderRep
; // header wrapper
173 BodyRep
*theBodyRep
; // body wrapper
177 } // namespace Adaptation
179 #endif /* SQUID__E_CAP__MESSAGE_REP_H */