}
void
-HttpReply::packHeadersInto(Packable * p) const
+HttpReply::packHeadersUsingFastPacker(Packable &p) const
{
- sline.packInto(p);
- header.packInto(p);
- p->append("\r\n", 2);
+ sline.packInto(&p);
+ header.packInto(&p);
+ p.append("\r\n", 2);
}
void
-HttpReply::packInto(Packable * p) const
+HttpReply::packHeadersUsingSlowPacker(Packable &p) const
{
- packHeadersInto(p);
- body.packInto(p);
+ MemBuf buf;
+ buf.init();
+ packHeadersUsingFastPacker(buf);
+ p.append(buf.content(), buf.contentSize());
+}
+
+void
+HttpReply::packInto(MemBuf &buf) const
+{
+ packHeadersUsingFastPacker(buf);
+ body.packInto(&buf);
}
/* create memBuf, create mem-based packer, pack, destroy packer, return MemBuf */
{
MemBuf *mb = new MemBuf;
mb->init();
- packInto(mb);
+ packInto(*mb);
return mb;
}
int validatorsMatch (HttpReply const *other) const;
- void packHeadersInto(Packable * p) const;
+ /// adds status line and header to the given Packable
+ /// assumes that `p` can quickly process small additions
+ void packHeadersUsingFastPacker(Packable &p) const;
+ /// same as packHeadersUsingFastPacker() but assumes that `p` cannot quickly process small additions
+ void packHeadersUsingSlowPacker(Packable &p) const;
/** Clone this reply.
* Could be done as a copy-contructor but we do not want to accidently copy a HttpReply..
void hdrCacheClean();
- void packInto(Packable * p) const;
+ void packInto(MemBuf &) const;
/* ez-routines */
/** \return construct 304 reply and pack it into a MemBuf */
Must(update.stale.anchor);
ShmWriter writer(*this, update.entry, update.fresh.fileNo);
- reply.packHeadersInto(&writer);
+ reply.packHeadersUsingSlowPacker(writer);
const uint64_t freshHdrSz = writer.totalWritten;
debugs(20, 7, "fresh hdr_sz: " << freshHdrSz << " diff: " << (freshHdrSz - staleHdrSz));
assert(rep);
buffer();
- rep->packHeadersInto(this);
+ rep->packHeadersUsingSlowPacker(*this);
mem_obj->markEndOfReplyHeaders();
rep->body.packInto(this);
{STUB_NOP}
HttpReply::~HttpReply() STUB
void HttpReply::setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires_) STUB
-void HttpReply::packHeadersInto(Packable *) const STUB
+void HttpReply::packHeadersUsingFastPacker(Packable&) const STUB
+void HttpReply::packHeadersUsingSlowPacker(Packable&) const STUB
void HttpReply::reset() STUB
void httpBodyPackInto(const HttpBody *, Packable *) STUB
bool HttpReply::sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false)
StoreEntry *const pe = createEntry(i);
pe->buffer();
- pe->getReply()->packHeadersInto(pe);
+ pe->getReply()->packHeadersUsingSlowPacker(*pe);
pe->flush();
pe->timestampsSet();
pe->complete();
pe->setPublicKey();
pe->buffer();
- pe->getReply()->packHeadersInto(pe);
+ pe->getReply()->packHeadersUsingSlowPacker(*pe);
pe->flush();
pe->timestampsSet();
pe->complete();