18#if HAVE_LIBECAP_COMMON_AREA_H
19#include <libecap/common/area.h>
21#if HAVE_LIBECAP_COMMON_NAMED_VALUES_H
22#include <libecap/common/named_values.h>
24#if HAVE_LIBECAP_COMMON_NAMES_H
25#include <libecap/common/names.h>
27#if HAVE_LIBECAP_COMMON_VERSION_H
28#include <libecap/common/version.h>
41 theHeader.hasNamed(name.image().c_str(), name.image().size()) :
42 static_cast<bool>(theHeader.has(squidId));
45Adaptation::Ecap::HeaderRep::Value
50 theHeader.getByName(name.image().c_str()) :
51 theHeader.getStrOrList(squidId);
52 return value.
size() > 0 ?
53 Value::FromTempString(value.
termedBuf()) : Value();
61 value.toString().
c_str());
62 theHeader.addEntry(e);
73 theHeader.delByName(name.image().c_str());
75 theHeader.delById(squidId);
86 const Name name(std::string(e->name.rawContent(), e->name.length()));
87 name.assignHostId(e->id);
88 visitor.visit(name, Value(e->value.rawBuf(), e->value.size()));
97 theMessage.packInto(&mb,
true);
106 Must(theMessage.parse(buf.start, buf.size,
true, &
error));
112 if (name.assignedHostId())
126 return libecap::Version(theMessage.http_ver.major,
127 theMessage.http_ver.minor);
133 theMessage.http_ver.major = aVersion.majr;
134 theMessage.http_ver.minor = aVersion.minr;
141 switch (theMessage.http_ver.protocol) {
143 return libecap::protocolHttp;
145 return libecap::protocolHttps;
147 return libecap::protocolFtp;
149 return libecap::protocolWais;
151 return libecap::protocolWhois;
153 return libecap::protocolUrn;
185 theMessage.http_ver.protocol = TranslateProtocolId(p);
191 if (name.assignedHostId())
208 const auto ok = theMessage.url.parse(theMessage.method,
SBuf(aUri.toString()));
215 const SBuf &fullUrl = theMessage.effectiveRequestUri();
225 if (aMethod.assignedHostId()) {
226 const int id = aMethod.hostId();
231 const std::string &image = aMethod.image();
232 theMessage.method.HttpRequestMethodXXX(image.c_str());
239 switch (theMessage.method.id()) {
241 return libecap::methodGet;
243 return libecap::methodPost;
245 return libecap::methodPut;
247 return libecap::methodHead;
249 return libecap::methodConnect;
251 return libecap::methodDelete;
253 return libecap::methodTrace;
255 return Name(theMessage.method.image().toStdString());
293 theMessage.sline.set(theMessage.sline.version,
static_cast<Http::StatusCode>(code),
nullptr);
300 return static_cast<int>(theMessage.sline.status());
308 theMessage.sline.resetReason();
314 return Area::FromTempString(std::string(theMessage.sline.reason()));
351 Must(aBody !=
nullptr);
358 return (theBody !=
nullptr && theBody->bodySizeKnown()) ?
BodySize(theBody->bodySize()) :
BodySize();
364 theMessage(rawHeader), theFirstLineRep(nullptr),
365 theHeaderRep(nullptr), theBodyRep(nullptr)
386 delete theFirstLineRep;
389libecap::shared_ptr<libecap::Message>
394 libecap::shared_ptr<libecap::Message> res(
new MessageRep(hdr));
397 if (theMessage.header->body_pipe !=
nullptr)
406 return *theFirstLineRep;
409const libecap::FirstLine &
412 return *theFirstLineRep;
418 return *theHeaderRep;
421const libecap::Header &
424 return *theHeaderRep;
437 Must(!theMessage.body_pipe);
438 theBodyRep =
new BodyRep(
nullptr);
444 Must(theBodyRep !=
nullptr);
445 Must(!theMessage.header->body_pipe);
446 Must(!theMessage.body_pipe);
447 theMessage.header->body_pipe =
new BodyPipe(x);
448 theMessage.body_pipe = theMessage.header->body_pipe;
449 theBodyRep->tie(theMessage.body_pipe);
void error(char *format,...)
BodyRep(const BodyPipe::Pointer &aBody)
BodySize bodySize() const override
libecap::BodySize BodySize
void tie(const BodyPipe::Pointer &aBody)
libecap::Version version() const
static AnyP::ProtocolType TranslateProtocolId(const Name &name)
FirstLineRep(Http::Message &aMessage)
Adaptation::Message theMessage
MessageRep(Http::Message *rawHeader)
libecap::FirstLine * theFirstLineRep
libecap::Body * body() override
libecap::FirstLine & firstLine() override
libecap::Header & header() override
libecap::shared_ptr< libecap::Message > clone() const override
void tieBody(Ecap::XactionRep *x)
libecap::Version version() const override
Name method() const override
Area uri() const override
RequestLineRep(HttpRequest &aMessage)
Name protocol() const override
int statusCode() const override
libecap::Version version() const override
Name protocol() const override
Area reasonPhrase() const override
StatusLineRep(HttpReply &aMessage)
BodyPipePointer body_pipe
common parts of HttpRequest and HttpReply
BodyPipe::Pointer body_pipe
optional pipeline to receive message body
void init(mb_size_t szInit, mb_size_t szMax)
char * content()
start of the added data
mb_size_t contentSize() const
available data size
const char * rawContent() const
size_type length() const
Returns the number of bytes stored in SBuf.
char const * termedBuf() const
const libecap::Name protocolIcp
const libecap::Name protocolUnknown
const libecap::Name protocolHtcp
const libecap::Name protocolIcy
enum Http::_method_t MethodType