]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/ecap/MessageRep.h
2 * DEBUG: section 93 eCAP Interface
5 #ifndef SQUID__ECAP__MESSAGE_REP_H
6 #define SQUID__ECAP__MESSAGE_REP_H
8 #include "adaptation/forward.h"
9 #include "adaptation/Message.h"
10 #include "anyp/ProtocolType.h"
12 #include "HttpHeader.h"
13 #include <libecap/common/message.h>
14 #include <libecap/common/header.h>
15 #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 /* libecap::Header API */
39 virtual bool hasAny(const Name
&name
) const;
40 virtual Value
value(const Name
&name
) const;
41 virtual void add(const Name
&name
, const Value
&value
);
42 virtual void removeAny(const Name
&name
);
43 virtual void visitEach(libecap::NamedValueVisitor
&visitor
) const;
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
55 // Helps translate Squid HttpMsg into libecap::FirstLine (see children).
59 typedef libecap::Name Name
;
62 FirstLineRep(HttpMsg
&aMessage
);
64 libecap::Version
version() const;
65 void version(const libecap::Version
&aVersion
);
66 Name
protocol() const;
67 void protocol(const Name
&aProtocol
);
70 static AnyP::ProtocolType
TranslateProtocolId(const Name
&name
);
73 HttpMsg
&theMessage
; // the message which first line is being translated
76 // Translates Squid HttpRequest into libecap::RequestLine.
77 class RequestLineRep
: public libecap::RequestLine
, public FirstLineRep
80 // typedef libecap::Name Name;
81 typedef libecap::Area Area
;
84 RequestLineRep(HttpRequest
&aMessage
);
86 /* libecap::RequestLine API */
87 virtual void uri(const Area
&aUri
);
88 virtual Area
uri() const;
89 virtual void method(const Name
&aMethod
);
90 virtual Name
method() const;
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
);
97 HttpRequest
&theMessage
; // the request header being translated to libecap
100 // Translates Squid HttpReply into libecap::StatusLine.
101 class StatusLineRep
: public libecap::StatusLine
, public FirstLineRep
104 typedef libecap::Name Name
;
105 typedef libecap::Area Area
;
108 StatusLineRep(HttpReply
&aMessage
);
110 /* libecap::StatusLine API */
111 virtual void statusCode(int code
);
112 virtual int statusCode() const;
113 virtual void reasonPhrase(const Area
&phrase
);
114 virtual Area
reasonPhrase() const;
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
);
121 HttpReply
&theMessage
; // the request header being translated to libecap
124 // Translates Squid BodyPipe into libecap::Body.
125 class BodyRep
: public libecap::Body
128 typedef libecap::BodySize BodySize
;
131 BodyRep(const BodyPipe::Pointer
&aBody
); // using NULL pointer? see tie()
133 void tie(const BodyPipe::Pointer
&aBody
); // late binding if !theBody;
136 virtual BodySize
bodySize() const;
139 BodyPipe::Pointer theBody
; // the body being translated to libecap
142 // Translates Squid Adaptation::Message into libecap::Message.
143 class MessageRep
: public libecap::Message
146 explicit MessageRep(HttpMsg
*rawHeader
);
147 virtual ~MessageRep();
149 /* libecap::Message API */
150 virtual libecap::shared_ptr
<libecap::Message
> clone() const;
151 virtual libecap::FirstLine
&firstLine();
152 virtual const libecap::FirstLine
&firstLine() const;
153 virtual libecap::Header
&header();
154 virtual const libecap::Header
&header() const;
155 virtual void addBody();
156 virtual libecap::Body
*body();
157 virtual const libecap::Body
*body() const;
159 void tieBody(Ecap::XactionRep
*x
); // to a specific transaction
161 Adaptation::Message
&raw() { return theMessage
; } // for host access
162 const Adaptation::Message
&raw() const { return theMessage
; } // for host
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
172 } // namespace Adaptation
174 #endif /* SQUID__E_CAP__MESSAGE_REP_H */