explicit MessageRep(HttpMsg *rawHeader);
virtual ~MessageRep();
- virtual libecap::shared_ptr<libecap::Message> clone() const;
+ virtual libecap::shared_ptr<libecap::Message> clone() const;
- virtual libecap::FirstLine &firstLine();
- virtual const libecap::FirstLine &firstLine() const;
+ virtual libecap::FirstLine &firstLine();
+ virtual const libecap::FirstLine &firstLine() const;
virtual libecap::Header &header();
virtual const libecap::Header &header() const;
virtual void addBody();
virtual libecap::Body *body();
virtual const libecap::Body *body() const;
- void tieBody(Ecap::XactionRep *x); // to a specific transaction
+ void tieBody(Ecap::XactionRep *x); // to a specific transaction
- Adaptation::Message &raw() { return theMessage; } // for host access
- const Adaptation::Message &raw() const { return theMessage; } // for host
+ Adaptation::Message &raw() { return theMessage; } // for host access
+ const Adaptation::Message &raw() const { return theMessage; } // for host
private:
Adaptation::Message theMessage; // the message being translated to libecap
// this code does not maintain proxying* and canAccessVb states; should it?
if (theAnswerRep != NULL) {
- BodyPipe::Pointer body_pipe = answer().body_pipe;
- if (body_pipe != NULL) {
- Must(body_pipe->stillProducing(this));
- stopProducingFor(body_pipe, false);
- }
- }
+ BodyPipe::Pointer body_pipe = answer().body_pipe;
+ if (body_pipe != NULL) {
+ Must(body_pipe->stillProducing(this));
+ stopProducingFor(body_pipe, false);
+ }
+ }
{
- BodyPipe::Pointer body_pipe = theVirginRep.raw().body_pipe;
- if (body_pipe != NULL) {
- Must(body_pipe->stillConsuming(this));
- stopConsumingFrom(body_pipe);
- }
- }
+ BodyPipe::Pointer body_pipe = theVirginRep.raw().body_pipe;
+ if (body_pipe != NULL) {
+ Must(body_pipe->stillConsuming(this));
+ stopConsumingFrom(body_pipe);
+ }
+ }
terminateMaster();
Adaptation::Initiate::swanSong();
Adaptation::Message &
Ecap::XactionRep::answer()
{
- MessageRep *rep = dynamic_cast<MessageRep*>(theAnswerRep.get());
- Must(rep);
+ MessageRep *rep = dynamic_cast<MessageRep*>(theAnswerRep.get());
+ Must(rep);
return rep->raw();
}
AdapterXaction x = theMaster;
theMaster.reset();
x->stop();
- }
+ }
}
bool
if (proxyingVb == opUndecided)
proxyingVb = opNever;
- HttpMsg *clone = theVirginRep.raw().header->clone();
+ HttpMsg *clone = theVirginRep.raw().header->clone();
// check that clone() copies the pipe so that we do not have to
- Must(!theVirginRep.raw().header->body_pipe == !clone->body_pipe);
+ Must(!theVirginRep.raw().header->body_pipe == !clone->body_pipe);
sendAnswer(clone);
Must(done());
}
theAnswerRep = m;
Must(proxyingAb == opUndecided);
- HttpMsg *msg = answer().header;
+ HttpMsg *msg = answer().header;
if (!theAnswerRep->body()) { // final, bodyless answer
proxyingAb = opNever;
sendAnswer(msg);
- } else { // got answer headers but need to handle body
+ } else { // got answer headers but need to handle body
proxyingAb = opOn;
- Must(!msg->body_pipe); // only host can set body pipes
+ Must(!msg->body_pipe); // only host can set body pipes
MessageRep *rep = dynamic_cast<MessageRep*>(theAnswerRep.get());
- Must(rep);
- rep->tieBody(this); // sets us as a producer
- Must(msg->body_pipe != NULL); // check tieBody
+ Must(rep);
+ rep->tieBody(this); // sets us as a producer
+ Must(msg->body_pipe != NULL); // check tieBody
sendAnswer(msg);
// nsize means no size limit: all content starting from offset
const size_t size = s == libecap::nsize ?
- haveSize - offset : static_cast<size_t>(s);
+ haveSize - offset : static_cast<size_t>(s);
// XXX: optimize by making theBody a shared_ptr (see Area::FromTemp*() src)
return libecap::Area::FromTempBuffer(p->buf().content() + offset,
- min(static_cast<size_t>(haveSize - offset), size));
+ min(static_cast<size_t>(haveSize - offset), size));
}
void
const libecap::Area c = theMaster->abContent(0, libecap::nsize);
debugs(93,5, HERE << " up to " << c.size << " bytes");
if (const size_t used = answer().body_pipe->putMoreData(c.start, c.size))
- theMaster->abContentShift(used);
+ theMaster->abContentShift(used);
}
const char *
if (!canAccessVb)
buf.append("x", 1);
if (vp != NULL && vp->stillConsuming(this)) {
- buf.append("Vb", 2);
+ buf.append("Vb", 2);
buf.append(vp->status(), strlen(vp->status())); // XXX
- } else
+ } else
buf.append("V.", 2);
- }
+ }
if (proxyingAb == opOn) {
MessageRep *rep = dynamic_cast<MessageRep*>(theAnswerRep.get());
Must(rep);
- const BodyPipePointer &ap = rep->raw().body_pipe;
- if (ap != NULL && ap->stillProducing(this)) {
- buf.append(" Ab", 3);
- buf.append(ap->status(), strlen(ap->status())); // XXX
- } else
- buf.append(" A.", 3);
- }
+ const BodyPipePointer &ap = rep->raw().body_pipe;
+ if (ap != NULL && ap->stillProducing(this)) {
+ buf.append(" Ab", 3);
+ buf.append(ap->status(), strlen(ap->status())); // XXX
+ } else
+ buf.append(" A.", 3);
+ }
buf.Printf(" ecapx%d]", id);
XactionRep(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader, HttpRequest *virginCause, const Adaptation::ServicePointer &service);
virtual ~XactionRep();
- typedef libecap::shared_ptr<libecap::adapter::Xaction> AdapterXaction;
- void master(const AdapterXaction &aMaster); // establish a link
+ typedef libecap::shared_ptr<libecap::adapter::Xaction> AdapterXaction;
+ void master(const AdapterXaction &aMaster); // establish a link
// libecap::host::Xaction API
virtual libecap::Message &virgin();
virtual void noteAbContentDone(bool atEnd);
virtual void noteAbContentAvailable();
- // libecap::Callable API, via libecap::host::Xaction
- virtual bool callable() const;
+ // libecap::Callable API, via libecap::host::Xaction
+ virtual bool callable() const;
// BodyProducer API
virtual void noteMoreBodySpaceAvailable(RefCount<BodyPipe> bp);
void scheduleStop(const char *reason);
private:
- AdapterXaction theMaster; // the actual adaptation xaction we represent
+ AdapterXaction theMaster; // the actual adaptation xaction we represent
- MessageRep theVirginRep;
- MessageRep *theCauseRep;
+ MessageRep theVirginRep;
+ MessageRep *theCauseRep;
- typedef libecap::shared_ptr<libecap::Message> MessagePtr;
- MessagePtr theAnswerRep;
+ typedef libecap::shared_ptr<libecap::Message> MessagePtr;
+ MessagePtr theAnswerRep;
typedef enum { opUndecided, opOn, opComplete, opNever } OperationState;
- OperationState proxyingVb; // delivering virgin body from core to adapter
- OperationState proxyingAb; // delivering adapted body from adapter to core
- bool canAccessVb; // virgin BodyPipe content is accessible
+ OperationState proxyingVb; // delivering virgin body from core to adapter
+ OperationState proxyingAb; // delivering adapted body from adapter to core
+ bool canAccessVb; // virgin BodyPipe content is accessible
- CBDATA_CLASS2(XactionRep);
+ CBDATA_CLASS2(XactionRep);
};
} // namespace Ecap