]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/ecap/MessageRep.h
3 * DEBUG: section 93 eCAP Interface
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>
29 // Translates Squid HttpMsg into libecap::Header.
30 class HeaderRep
: public libecap::Header
33 typedef libecap::Name Name
;
34 typedef libecap::Area Area
;
37 HeaderRep(HttpMsg
&aMessage
);
39 virtual bool hasAny(const Name
&name
) const;
40 virtual Value
value(const Name
&name
) const;
42 virtual void add(const Name
&name
, const Value
&value
);
43 virtual void removeAny(const Name
&name
);
45 virtual Area
image() const;
46 virtual void parse(const Area
&buf
); // throws on failures
49 static http_hdr_type
TranslateHeaderId(const Name
&name
);
52 HttpHeader
&theHeader
; // the header being translated to libecap
53 HttpMsg
&theMessage
; // the message being translated to libecap
57 // Helps translate Squid HttpMsg into libecap::FirstLine (see children).
61 typedef libecap::Name Name
;
64 FirstLineRep(HttpMsg
&aMessage
);
66 libecap::Version
version() const;
67 void version(const libecap::Version
&aVersion
);
68 Name
protocol() const;
69 void protocol(const Name
&aProtocol
);
72 static protocol_t
TranslateProtocolId(const Name
&name
);
75 HttpMsg
&theMessage
; // the message which first line is being translated
78 // Translates Squid HttpRequest into libecap::RequestLine.
79 class RequestLineRep
: public libecap::RequestLine
, public FirstLineRep
82 // typedef libecap::Name Name;
83 typedef libecap::Area Area
;
86 RequestLineRep(HttpRequest
&aMessage
);
88 virtual void uri(const Area
&aUri
);
89 virtual Area
uri() const;
91 virtual void method(const Name
&aMethod
);
92 virtual Name
method() const;
94 virtual libecap::Version
version() const;
95 virtual void version(const libecap::Version
&aVersion
);
96 virtual Name
protocol() const;
97 virtual void protocol(const Name
&aProtocol
);
100 HttpRequest
&theMessage
; // the request header being translated to libecap
103 // Translates Squid HttpReply into libecap::StatusLine.
104 class StatusLineRep
: public libecap::StatusLine
, public FirstLineRep
107 typedef libecap::Name Name
;
108 typedef libecap::Area Area
;
111 StatusLineRep(HttpReply
&aMessage
);
113 virtual void statusCode(int code
);
114 virtual int statusCode() const;
116 virtual void reasonPhrase(const Area
&phrase
);
117 virtual Area
reasonPhrase() const;
119 virtual libecap::Version
version() const;
120 virtual void version(const libecap::Version
&aVersion
);
121 virtual Name
protocol() const;
122 virtual void protocol(const Name
&aProtocol
);
125 HttpReply
&theMessage
; // the request header being translated to libecap
129 // Translates Squid BodyPipe into libecap::Body.
130 class BodyRep
: public libecap::Body
133 typedef libecap::BodySize BodySize
;
136 BodyRep(const BodyPipe::Pointer
&aBody
); // using NULL pointer? see tie()
138 void tie(const BodyPipe::Pointer
&aBody
); // late binding if !theBody;
141 virtual BodySize
bodySize() const;
144 BodyPipe::Pointer theBody
; // the body being translated to libecap
147 // Translates Squid Adaptation::Message into libecap::Message.
148 class MessageRep
: public libecap::Message
151 explicit MessageRep(HttpMsg
*rawHeader
);
152 virtual ~MessageRep();
154 virtual libecap::shared_ptr
<libecap::Message
> clone() const;
156 virtual libecap::FirstLine
&firstLine();
157 virtual const libecap::FirstLine
&firstLine() const;
159 virtual libecap::Header
&header();
160 virtual const libecap::Header
&header() const;
162 virtual void addBody();
163 virtual libecap::Body
*body();
164 virtual const libecap::Body
*body() const;
165 void tieBody(Ecap::XactionRep
*x
); // to a specific transaction
167 Adaptation::Message
&raw() { return theMessage
; } // for host access
168 const Adaptation::Message
&raw() const { return theMessage
; } // for host
171 Adaptation::Message theMessage
; // the message being translated to libecap
172 libecap::FirstLine
*theFirstLineRep
; // request or status line wrapper
173 HeaderRep
*theHeaderRep
; // header wrapper
174 BodyRep
*theBodyRep
; // body wrapper
178 } // namespace Adaptation
180 #endif /* SQUID__E_CAP__MESSAGE_REP_H */