// TODO: parse more than just the request-line
bool isDone() const {return completedState_==HTTP_PARSE_FIRST;}
+ /// size in bytes of the first line (request-line)
+ /// including CRLF terminator
+ int64_t firstLineSize() const {return req.end - req.start + 1;}
+
+ /// size in bytes of the message headers including CRLF terminator
+ /// but excluding request-line bytes
+ int64_t headerBlockSize() const {return hdr_end - hdr_start + 1;}
+
+ /// size in bytes of HTTP message block, includes request-line and mime headers
+ /// excludes any body/entity/payload bytes
+ int64_t messageHeaderSize() const {return hdr_end - req.start + 1;}
+
+ /// buffer containing HTTP mime headers
+ // convert to SBuf
+ const char *rawHeaderBuf() {return buf + hdr_start;}
+
/**
* Attempt to parse the first line of a new request message.
*
// Legacy functions
int HttpParserParseReqLine(HttpParser *hp);
-#define HttpParserReqSz(hp) ( (hp)->req.end - (hp)->req.start + 1 )
-#define HttpParserHdrSz(hp) ( (hp)->hdr_end - (hp)->hdr_start + 1 )
-#define HttpParserHdrBuf(hp) ( (hp)->buf + (hp)->hdr_start )
-#define HttpParserRequestLen(hp) ( (hp)->hdr_end - (hp)->req.start + 1 )
-
#endif /* _SQUID_SRC_HTTPPARSER_H */
}
} else {
debugs(33, 3, "parseHttpRequest: Missing HTTP identifier");
- req_sz = HttpParserReqSz(hp);
+ req_sz = hp->firstLineSize();
}
/* We know the whole request is in hp->buf now */
debugs(33, 3, "parseHttpRequest: end = {" << end << "}");
debugs(33, 3, "parseHttpRequest: prefix_sz = " <<
- (int) HttpParserRequestLen(hp) << ", req_line_sz = " <<
- HttpParserReqSz(hp));
+ hp->messageHeaderSize() << ", request-line-size=" <<
+ hp->firstLineSize());
/* Ok, all headers are received */
http = new ClientHttpRequest(csd);
- http->req_sz = HttpParserRequestLen(hp);
+ http->req_sz = hp->messageHeaderSize();
result = ClientSocketContextNew(csd->clientConnection, http);
tempBuffer.data = result->reqbuf;
tempBuffer.length = HTTP_REQBUF_SZ;
(http_ver.major > 1) ) {
clientStreamNode *node = context->getClientReplyContext();
- debugs(33, 5, "Unsupported HTTP version discovered. :\n" << HttpParserHdrBuf(hp));
+ debugs(33, 5, "Unsupported HTTP version discovered. :\n" << hp->rawHeaderBuf());
conn->quitAfterError(request.getRaw());
// setLogUri should called before repContext->setReplyToError
setLogUri(http, http->uri, true);
clientReplyContext *repContext = dynamic_cast<clientReplyContext *>(node->data.getRaw());
assert (repContext);
repContext->setReplyToError(ERR_UNSUP_HTTPVERSION, Http::scHttpVersionNotSupported, method, http->uri,
- conn->clientConnection->remote, NULL, HttpParserHdrBuf(hp), NULL);
+ conn->clientConnection->remote, NULL, hp->rawHeaderBuf(), NULL);
assert(context->http->out.offset == 0);
context->pullData();
goto finish;
/* compile headers */
/* we should skip request line! */
/* XXX should actually know the damned buffer size here */
- if (http_ver.major >= 1 && !request->parseHeader(HttpParserHdrBuf(hp), HttpParserHdrSz(hp))) {
+ if (http_ver.major >= 1 && !request->parseHeader(hp->rawHeaderBuf(), hp->headerBlockSize())) {
clientStreamNode *node = context->getClientReplyContext();
- debugs(33, 5, "Failed to parse request headers:\n" << HttpParserHdrBuf(hp));
+ debugs(33, 5, "Failed to parse request headers:\n" << hp->rawHeaderBuf());
conn->quitAfterError(request.getRaw());
// setLogUri should called before repContext->setReplyToError
setLogUri(http, http->uri, true);