bufsiz = 0;
parseOffset_ = 0;
req.start = req.end = -1;
- hdr_start = hdr_end = -1;
req.m_start = req.m_end = -1;
req.u_start = req.u_end = -1;
req.v_start = req.v_end = -1;
msgProtocol_ = AnyP::ProtocolVersion();
method_ = NULL;
- mimeHeaderBytes_ = 0;
+ mimeHeaderBlock_.clear();
}
void
// stage 3: locate the mime header block
if (completedState_ == HTTP_PARSE_FIRST) {
-
- // NP: set these to same value representing 0-byte headers.
- hdr_start = req.end + 1;
- hdr_end = hdr_start;
-
// HTTP/1.x request-line is valid and parsing completed.
if (msgProtocol_.major == 1) {
/* NOTE: HTTP/0.9 requests do not have a mime header block.
* So the rest of the code will need to deal with '0'-byte headers
* (ie, none, so don't try parsing em)
*/
- if ((mimeHeaderBytes_ = headersEnd(buf+parseOffset_, bufsiz-parseOffset_)) == 0) {
+ int64_t mimeHeaderBytes = 0;
+ if ((mimeHeaderBytes = headersEnd(buf+parseOffset_, bufsiz-parseOffset_)) == 0) {
debugs(33, 5, "Incomplete request, waiting for end of headers");
return false;
}
-
- hdr_start = req.end + 1;
- hdr_end = parseOffset_ + mimeHeaderBytes_ - 1;
+ mimeHeaderBlock_.assign(&buf[req.end+1], mimeHeaderBytes);
} else
debugs(33, 3, "Missing HTTP/1.x identifier");
#include "http/forward.h"
#include "http/ProtocolVersion.h"
#include "http/StatusCode.h"
+#include "SBuf.h"
namespace Http {
/// size in bytes of the message headers including CRLF terminator(s)
/// but excluding request-line bytes
- int64_t headerBlockSize() const {return mimeHeaderBytes_;}
+ int64_t headerBlockSize() const {return mimeHeaderBlock_.length();}
/// size in bytes of HTTP message block, includes request-line and mime headers
/// excludes any body/entity/payload bytes
/// excludes any garbage prefix before the request-line
int64_t messageHeaderSize() const {return firstLineSize() + headerBlockSize();}
- /// buffer containing HTTP mime headers
- // TODO: convert to SBuf
- const char *rawHeaderBuf() {return buf + hdr_start;}
+ /// buffer containing HTTP mime headers, excluding request or status line.
+ const char *rawHeaderBuf() {return mimeHeaderBlock_.c_str();}
/** Attempt to parse a request.
* \return true if a valid request was parsed.
/// the HTTP method if this is a request method
const HttpRequestMethodPointer & method() const {return method_;}
- // Offsets for pieces of the MiME Header segment
- // \deprecated use rawHeaderBuf() and headerBlockSize() instead
- int hdr_start, hdr_end;
-
// TODO: Offsets for pieces of the (HTTP reply) Status-Line as per RFC 2616
/** HTTP status code to be used on the invalid-request error page
/// what request method has been found on the first line
HttpRequestMethodPointer method_;
- /// number of bytes in the mime header block
- int64_t mimeHeaderBytes_;
+ /// buffer holding the mime headers
+ SBuf mimeHeaderBlock_;
};
} // namespace Http