42
Http::One::Parser::grabMimeBlock(const char *which, const size_t limit)
44
// MIME headers block exist in (only) HTTP/1.x and ICY
45
const bool expectMime = (msgProtocol_.protocol == AnyP::PROTO_HTTP && msgProtocol_.major == 1) ||
46
msgProtocol_.protocol == AnyP::PROTO_ICY;
49
/* NOTE: HTTP/0.9 messages do not have a mime header block.
50
* So the rest of the code will need to deal with '0'-byte headers
51
* (ie, none, so don't try parsing em)
53
// XXX: c_str() reallocates. performance regression.
54
if (SBuf::size_type mimeHeaderBytes = headersEnd(buf_.c_str(), buf_.length())) {
56
// Squid could handle these headers, but admin does not want to
57
if (firstLineSize() + mimeHeaderBytes >= limit) {
58
debugs(33, 5, "Too large " << which);
59
parseStatusCode = Http::scHeaderTooLarge;
60
buf_.consume(mimeHeaderBytes);
61
parsingStage_ = HTTP_PARSE_DONE;
65
mimeHeaderBlock_ = buf_.consume(mimeHeaderBytes);
66
debugs(74, 5, "mime header (0-" << mimeHeaderBytes << ") {" << mimeHeaderBlock_ << "}");
68
} else { // headersEnd() == 0
69
if (buf_.length()+firstLineSize() >= limit) {
70
debugs(33, 5, "Too large " << which);
71
parseStatusCode = Http::scHeaderTooLarge;
72
parsingStage_ = HTTP_PARSE_DONE;
74
debugs(33, 5, "Incomplete " << which << ", waiting for end of headers");
79
debugs(33, 3, "Missing HTTP/1.x identifier");
81
// NP: we do not do any further stages here yet so go straight to DONE
82
parsingStage_ = HTTP_PARSE_DONE;
40
87
// arbitrary maximum-length for headers which can be found by Http1Parser::getHeaderField()
41
88
#define GET_HDR_SZ 1024