virtual void reset();
- /**
- \retval true on success
- \retval false and sets *error to zero when needs more data
- \retval false and sets *error to a positive Http::StatusCode on error
- */
+ /* Http::Message API */
virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error);
/** \par public, readable; never update these or their .hdr equivalents directly */
// find the end of headers
const size_t hdr_len = headersEnd(buf, sz);
+ if (hdr_len > Config.maxReplyHeaderSize || (hdr_len == 0 && sz > Config.maxReplyHeaderSize)) {
+ debugs(58, 3, "input too large: " << hdr_len << " or " << sz << " > " << Config.maxReplyHeaderSize);
+ *error = Http::scHeaderTooLarge;
+ return false;
+ }
+
// sanity check the start line to see if this is in fact an HTTP message
if (!sanityCheckStartLine(buf, hdr_len, error)) {
// NP: sanityCheck sets *error and sends debug warnings on syntax errors.
return false;
}
- if (hdr_len > Config.maxReplyHeaderSize || (hdr_len <= 0 && sz > Config.maxReplyHeaderSize)) {
- debugs(58, DBG_IMPORTANT, "Too large reply header (" << hdr_len << " > " << Config.maxReplyHeaderSize);
- *error = Http::scHeaderTooLarge;
- return false;
- }
-
- if (hdr_len <= 0) {
- debugs(58, 3, "failed to find end of headers (eof: " << eof << ") in '" << buf << "'");
-
- if (eof) // iff we have seen the end, this is an error
- *error = Http::scInvalidHeader;
-
- return false;
- }
+ assert(hdr_len > 0); // sanityCheckStartLine() rejects buffers that cannot be parsed
const int res = httpMsgParseStep(buf, sz, eof);
{
packFirstLineInto(&mb, true);
}
-
/**
* Validate the message start line is syntactically correct.
* Set HTTP error status according to problems found.
+ * Zero hdr_len is treated as a serious problem.
*
* \retval true Status line has no serious problems.
* \retval false Status line has a serious problem. Correct response is indicated by error.