]>
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>
27 // Translates Squid HttpMsg into libecap::Header.
28 class HeaderRep
: public libecap::Header
31 typedef libecap::Name Name
;
32 typedef libecap::Area Area
;
35 HeaderRep(HttpMsg
&aMessage
);
37 virtual bool hasAny(const Name
&name
) const;
38 virtual Value
value(const Name
&name
) const;
40 virtual void add(const Name
&name
, const Value
&value
);
41 virtual void removeAny(const Name
&name
);
43 virtual Area
image() const;
44 virtual void parse(const Area
&buf
); // throws on failures
47 static http_hdr_type
TranslateHeaderId(const Name
&name
);
50 HttpHeader
&theHeader
; // the header being translated to libecap
51 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 protocol_t
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 virtual void uri(const Area
&aUri
);
87 virtual Area
uri() const;
89 virtual void method(const Name
&aMethod
);
90 virtual Name
method() const;
92 virtual libecap::Version
version() const;
93 virtual void version(const libecap::Version
&aVersion
);
94 virtual Name
protocol() const;
95 virtual void protocol(const Name
&aProtocol
);
98 HttpRequest
&theMessage
; // the request header being translated to libecap
101 // Translates Squid HttpReply into libecap::StatusLine.
102 class StatusLineRep
: public libecap::StatusLine
, public FirstLineRep
105 typedef libecap::Name Name
;
106 typedef libecap::Area Area
;
109 StatusLineRep(HttpReply
&aMessage
);
111 virtual void statusCode(int code
);
112 virtual int statusCode() const;
114 virtual void reasonPhrase(const Area
&phrase
);
115 virtual Area
reasonPhrase() const;
117 virtual libecap::Version
version() const;
118 virtual void version(const libecap::Version
&aVersion
);
119 virtual Name
protocol() const;
120 virtual void protocol(const Name
&aProtocol
);
123 HttpReply
&theMessage
; // the request header being translated to libecap
127 // Translates Squid BodyPipe into libecap::Body.
128 class BodyRep
: public libecap::Body
131 typedef libecap::BodySize BodySize
;
134 BodyRep(const BodyPipe::Pointer
&aBody
); // using NULL pointer? see tie()
136 void tie(const BodyPipe::Pointer
&aBody
); // late binding if !theBody;
139 virtual BodySize
bodySize() const;
142 BodyPipe::Pointer theBody
; // the body being translated to libecap
145 // Translates Squid Adaptation::Message into libecap::Message.
146 class MessageRep
: public libecap::Message
149 explicit MessageRep(HttpMsg
*rawHeader
);
150 virtual ~MessageRep();
152 virtual libecap::shared_ptr
<libecap::Message
> clone() const;
154 virtual libecap::FirstLine
&firstLine();
155 virtual const libecap::FirstLine
&firstLine() const;
157 virtual libecap::Header
&header();
158 virtual const libecap::Header
&header() const;
160 virtual void addBody();
161 virtual libecap::Body
*body();
162 virtual const libecap::Body
*body() const;
163 void tieBody(Ecap::XactionRep
*x
); // to a specific transaction
165 Adaptation::Message
&raw() { return theMessage
; } // for host access
166 const Adaptation::Message
&raw() const { return theMessage
; } // for host
169 Adaptation::Message theMessage
; // the message being translated to libecap
170 libecap::FirstLine
*theFirstLineRep
; // request or status line wrapper
171 HeaderRep
*theHeaderRep
; // header wrapper
172 BodyRep
*theBodyRep
; // body wrapper
177 #endif /* SQUID__E_CAP__MESSAGE_REP_H */