/*
- * $Id: HttpReply.cc,v 1.79 2005/11/07 22:00:38 wessels Exp $
+ * $Id: HttpReply.cc,v 1.80 2005/11/21 22:49:04 wessels Exp $
*
* DEBUG: section 58 HTTP Reply (Response)
* AUTHOR: Alex Rousskov
HDR_OTHER
};
-
/* module initialization */
void
httpReplyInitModule(void)
httpHeaderCalcMask(&Denied304HeadersMask, (const int *) Denied304HeadersArr, countof(Denied304HeadersArr));
}
-
HttpReply::HttpReply() : HttpMsg(hoReply), date (0), last_modified (0), expires (0), surrogate_control (NULL), content_range (NULL), keep_alive (0), protoPrefix("HTTP/")
{
init();
return 1;
}
-
void
HttpReply::updateOnNotModified(HttpReply const * freshRep)
{
hdrCacheInit();
}
-
/* internal routines */
time_t
{
return httpStatusLineParse(&sline, protoPrefix, blk_start, blk_end);
}
+
+/*
+ * Indicate whether or not we would usually expect an entity-body
+ * along with this response
+ */
+bool
+HttpReply::expectingBody(method_t req_method, ssize_t& theSize) const
+{
+ bool expectBody = true;
+
+ if (req_method == METHOD_HEAD)
+ expectBody = false;
+ else if (sline.status == HTTP_NO_CONTENT)
+ expectBody = false;
+ else if (sline.status == HTTP_NOT_MODIFIED)
+ expectBody = false;
+ else if (sline.status < HTTP_OK)
+ expectBody = false;
+ else
+ expectBody = true;
+
+ if (expectBody) {
+ if (httpHeaderHasListMember(&header, HDR_TRANSFER_ENCODING, "chunked", ','))
+ theSize = -1;
+ else if (content_length >= 0)
+ theSize = content_length;
+ else
+ theSize = -1;
+ }
+
+ return expectBody;
+}
/*
- * $Id: HttpReply.h,v 1.13 2005/11/07 22:00:38 wessels Exp $
+ * $Id: HttpReply.h,v 1.14 2005/11/21 22:49:04 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
bool do_clean;
public:
+ virtual bool expectingBody(method_t, ssize_t&) const;
void updateOnNotModified(HttpReply const *other);
/* absorb: copy the contents of a new reply to the old one, destroy new one */
void absorb(HttpReply * new_rep);