inmem_lo(0),
nclients(0),
smpCollapsed(false),
- request(nullptr),
ping_reply_callback(nullptr),
ircb_data(nullptr),
id(0),
debugs(20, 3, "new MemObject " << this);
memset(&start_ping, 0, sizeof(start_ping));
memset(&abort, 0, sizeof(abort));
- _reply = new HttpReply;
- HTTPMSGLOCK(_reply);
+ reply_ = new HttpReply;
}
MemObject::~MemObject()
#endif
- HTTPMSGUNLOCK(_reply);
-
ctx_exit(ctx); /* must exit before we free mem->url */
}
debugs(20, DBG_IMPORTANT, "MemObject->inmem_hi: " << data_hdr.endOffset());
debugs(20, DBG_IMPORTANT, "MemObject->inmem_lo: " << inmem_lo);
debugs(20, DBG_IMPORTANT, "MemObject->nclients: " << nclients);
- debugs(20, DBG_IMPORTANT, "MemObject->reply: " << _reply);
+ debugs(20, DBG_IMPORTANT, "MemObject->reply: " << reply_);
debugs(20, DBG_IMPORTANT, "MemObject->request: " << request);
debugs(20, DBG_IMPORTANT, "MemObject->logUri: " << logUri_);
debugs(20, DBG_IMPORTANT, "MemObject->storeId: " << storeId_);
}
-HttpReply const *
-MemObject::getReply() const
-{
- return _reply;
-}
-
-void
-MemObject::replaceHttpReply(HttpReply *newrep)
-{
- HTTPMSGUNLOCK(_reply);
- _reply = newrep;
- HTTPMSGLOCK(_reply);
-}
-
struct LowestMemReader : public unary_function<store_client, void> {
LowestMemReader(int64_t seed):current(seed) {}
{
const int hdr_sz = endOffset();
assert(hdr_sz >= 0);
- assert(_reply);
- _reply->hdr_sz = hdr_sz;
+ assert(reply_);
+ reply_->hdr_sz = hdr_sz;
}
int64_t
int64_t
MemObject::expectedReplySize() const
{
- debugs(20, 7, HERE << "object_sz: " << object_sz);
+ debugs(20, 7, "object_sz: " << object_sz);
if (object_sz >= 0) // complete() has been called; we know the exact answer
return object_sz;
- if (_reply) {
- const int64_t clen = _reply->bodySize(method);
- debugs(20, 7, HERE << "clen: " << clen);
- if (clen >= 0 && _reply->hdr_sz > 0) // yuck: Http::Message sets hdr_sz to 0
- return clen + _reply->hdr_sz;
+ if (reply_) {
+ const int64_t clen = reply_->bodySize(method);
+ debugs(20, 7, "clen: " << clen);
+ if (clen >= 0 && reply_->hdr_sz > 0) // yuck: Http::Message sets hdr_sz to 0
+ return clen + reply_->hdr_sz;
}
return -1; // not enough information to predict
data_hdr.freeContent();
inmem_lo = 0;
/* Should we check for clients? */
+ if (reply_)
+ reply_->reset();
}
int64_t
void write(const StoreIOBuffer &buf);
void unlinkRequest() { request = nullptr; }
- HttpReply const *getReply() const;
- void replaceHttpReply(HttpReply *newrep);
+ const HttpReplyPointer &getReply() const { return reply_; }
+ void replaceReply(const HttpReplyPointer &r) { reply_ = r; }
void stat (MemBuf * mb) const;
int64_t endOffset () const;
- void markEndOfReplyHeaders(); ///< sets _reply->hdr_sz to endOffset()
+ void markEndOfReplyHeaders(); ///< sets reply_->hdr_sz to endOffset()
/// negative if unknown; otherwise, expected object_sz, expected endOffset
/// maximum, and stored reply headers+body size (all three are the same)
int64_t expectedReplySize() const;
void kickReads();
private:
- HttpReply *_reply;
+ HttpReplyPointer reply_;
mutable String storeId_; ///< StoreId for our entry (usually request URI)
mutable String logUri_; ///< URI used for logging (usually request URI)
}
void
-clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String boundary, MemBuf * mb)
+clientPackRangeHdr(const HttpReplyPointer &rep, const HttpHdrRangeSpec * spec, String boundary, MemBuf * mb)
{
HttpHeader hdr(hoReply);
assert(rep);
void clientSetKeepaliveFlag(ClientHttpRequest *http);
/// append a "part" HTTP header (as in a multi-part/range reply) to the buffer
-void clientPackRangeHdr(const HttpReply *, const HttpHdrRangeSpec *, String boundary, MemBuf *);
+void clientPackRangeHdr(const HttpReplyPointer &, const HttpHdrRangeSpec *, String boundary, MemBuf *);
/// put terminating boundary for multiparts to the buffer
void clientPackTermBound(String boundary, MemBuf *);
MemObject *mem = http->storeEntry()->mem_obj;
assert(mem != NULL);
assert(http->request != NULL);
- /* mem->reply was wrong because it uses the UPSTREAM header length!!! */
- HttpReply const *curReply = mem->getReply();
+ /* mem->reply was wrong because it uses the UPSTREAM header length!!! */
if (headers_sz == 0)
/* haven't found end of headers yet */
return 0;
+ const HttpReplyPointer curReply(mem->getReply());
+
/*
* Figure out how much data we are supposed to send.
* If we are sending a body and we don't have a content-length,
if (!_peer->connection_auth)
return false;
- const HttpReply *rep = entry->mem_obj->getReply();
+ const HttpReplyPointer rep(entry->mem_obj->getReply());
/*The peer supports connection pinning and the http reply status
is not unauthorized, so the related connection can be pinned
debugs(22, 3, "Staleness = " << staleness);
- const auto *reply = (entry->mem_obj && entry->mem_obj->getReply() ? entry->mem_obj->getReply() : nullptr);
+ const HttpReplyPointer reply(entry->mem_obj && entry->mem_obj->getReply() ? entry->mem_obj->getReply() : nullptr);
// stale-if-error requires any failure be passed thru when its period is over.
if (request && reply && reply->cache_control &&
#include "squid.h"
#include "Generic.h"
-#include "HttpRequest.h"
+#include "HttpReply.h"
#include "mem_node.h"
#include "MemObject.h"
#include "profiler/Profiler.h"
/* Make sure the request knows the variance status */
if (request->vary_headers.isEmpty())
- request->vary_headers = httpMakeVaryMark(request.getRaw(), mem_obj->getReply());
+ request->vary_headers = httpMakeVaryMark(request.getRaw(), mem_obj->getReply().getRaw());
}
// TODO: storeGetPublic() calls below may create unlocked entries.
assert(store_status == STORE_PENDING);
// XXX: caller uses content offset, but we also store headers
- if (const HttpReply *reply = mem_obj->getReply())
+ if (const HttpReplyPointer reply = mem_obj->getReply())
writeBuffer.offset += reply->hdr_sz;
debugs(20, 5, "storeWrite: writing " << writeBuffer.length << " bytes for '" << getMD5Text() << "'");
}
HttpReply const *
-StoreEntry::getReply () const
+StoreEntry::getReply() const
{
- if (NULL == mem_obj)
- return NULL;
-
- return mem_obj->getReply();
+ return (mem_obj ? mem_obj->getReply().getRaw() : nullptr);
}
void
StoreEntry::reset()
{
assert (mem_obj);
- debugs(20, 3, "StoreEntry::reset: " << url());
+ debugs(20, 3, url());
mem_obj->reset();
- HttpReply *rep = (HttpReply *) getReply(); // bypass const
- rep->reset();
expires = lastModified_ = timestamp = -1;
}
return;
}
- mem_obj->replaceHttpReply(rep);
+ mem_obj->replaceReply(HttpReplyPointer(rep));
if (andStartWriting)
startWriting();
MemObject::MemObject() :
inmem_lo(0),
nclients(0),
- request(NULL),
ping_reply_callback(NULL),
ircb_data(NULL),
id(0),
object_sz(-1),
- swap_hdr_sz(0),
- _reply(NULL)
+ swap_hdr_sz(0)
{
memset(&clients, 0, sizeof(clients));
memset(&start_ping, 0, sizeof(start_ping));
memset(&abort, 0, sizeof(abort));
} // NOP instead of elided due to Store
-HttpReply const * MemObject::getReply() const
-{
- // XXX: required by testStore
- return NULL;
-}
const char *MemObject::storeId() const STUB_RETVAL(NULL)
const char *MemObject::logUri() const STUB_RETVAL(NULL)
void MemObject::setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod) STUB
DelayId MemObject::mostBytesAllowed() const STUB_RETVAL(DelayId())
#endif
void MemObject::write(const StoreIOBuffer &writeBuffer) STUB
-void MemObject::replaceHttpReply(HttpReply *newrep) STUB
int64_t MemObject::lowestMemReaderOffset() const STUB_RETVAL(0)
void MemObject::kickReads() STUB
int64_t MemObject::objectBytesOnDisk() const STUB_RETVAL(0)
void clientOpenListenSockets(void) STUB
void clientHttpConnectionsClose(void) STUB
void httpRequestFree(void *) STUB
-void clientPackRangeHdr(const HttpReply *, const HttpHdrRangeSpec *, String, MemBuf *) STUB
+void clientPackRangeHdr(const HttpReplyPointer &, const HttpHdrRangeSpec *, String, MemBuf *) STUB
void clientPackTermBound(String, MemBuf *) STUB
#include "squid.h"
#include "base/CharacterSet.h"
-#include "HttpRequest.h"
+#include "HttpReply.h"
#include "sbuf/Algorithms.h"
#include "sbuf/SBuf.h"
#include "sbuf/Stream.h"