/*
- * $Id: HttpMsg.cc,v 1.31 2006/09/20 11:38:14 adrian Exp $
+ * $Id: HttpMsg.cc,v 1.32 2006/09/26 13:30:09 adrian Exp $
*
* DEBUG: section 74 HTTP Message
* AUTHOR: Alex Rousskov
/* find end of headers */
int
-httpMsgIsolateHeaders(const char **parse_start, const char **blk_start, const char **blk_end)
+httpMsgIsolateHeaders(const char **parse_start, int l, const char **blk_start, const char **blk_end)
{
/*
* parse_start points to the first line of HTTP message *headers*,
* not including the request or status lines
*/
- size_t l = strlen(*parse_start);
size_t end = headersEnd(*parse_start, l);
int nnl;
return false;
}
- const int res = httpMsgParseStep(buf->content(), eof);
+ const int res = httpMsgParseStep(buf->content(), buf->contentSize(), eof);
if (res < 0) { // error
debugs(58, 3, "HttpMsg::parse: cannot parse isolated headers " <<
mb.init();
mb.append(buf, end);
mb.terminate();
- success = httpMsgParseStep(mb.buf, 0);
+ success = httpMsgParseStep(mb.buf, mb.size, 0);
mb.clean();
return success == 1;
}
* -1 -- parse error
*/
int
-HttpMsg::httpMsgParseStep(const char *buf, int atEnd)
+HttpMsg::httpMsgParseStep(const char *buf, int len, int atEnd)
{
const char *parse_start = buf;
+ int parse_len = len;
const char *blk_start, *blk_end;
const char **parse_end_ptr = &blk_end;
assert(parse_start);
*parse_end_ptr = parse_start;
hdr_sz = *parse_end_ptr - buf;
+ parse_len = parse_len - hdr_sz;
++pstate;
}
+ /*
+ * XXX This code uses parse_start; but if we're incrementally parsing then
+ * this code might not actually be given parse_start at the right spot (just
+ * after headers.) Grr.
+ */
if (pstate == psReadyToParseHeaders) {
- if (!httpMsgIsolateHeaders(&parse_start, &blk_start, &blk_end)) {
+ if (!httpMsgIsolateHeaders(&parse_start, parse_len, &blk_start, &blk_end)) {
if (atEnd) {
blk_start = parse_start, blk_end = blk_start + strlen(blk_start);
} else {
/*
- * $Id: HttpMsg.h,v 1.9 2006/04/18 12:25:50 robertc Exp $
+ * $Id: HttpMsg.h,v 1.10 2006/09/26 13:30:09 adrian Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
bool parseCharBuf(const char *buf, ssize_t end);
- int httpMsgParseStep(const char *buf, int atEnd);
+ int httpMsgParseStep(const char *buf, int len, int atEnd);
virtual int httpMsgParseError();
};
-SQUIDCEXTERN int httpMsgIsolateHeaders(const char **parse_start, const char **blk_start, const char **blk_end);
+SQUIDCEXTERN int httpMsgIsolateHeaders(const char **parse_start, int len, const char **blk_start, const char **blk_end);
#define HTTPMSGUNLOCK(a) if(a){(a)->_unlock();(a)=NULL;}
#define HTTPMSGLOCK(a) (a)->_lock()
/*
- * $Id: HttpRequest.cc,v 1.67 2006/05/29 21:44:18 robertc Exp $
+ * $Id: HttpRequest.cc,v 1.68 2006/09/26 13:30:09 adrian Exp $
*
* DEBUG: section 73 HTTP Request
* AUTHOR: Duane Wessels
}
int
-HttpRequest::parseHeader(const char *parse_start)
+HttpRequest::parseHeader(const char *parse_start, int len)
{
const char *blk_start, *blk_end;
- if (!httpMsgIsolateHeaders(&parse_start, &blk_start, &blk_end))
+ if (!httpMsgIsolateHeaders(&parse_start, len, &blk_start, &blk_end))
return 0;
int result = header.parse(blk_start, blk_end);
/*
- * $Id: HttpRequest.h,v 1.23 2006/05/29 21:44:18 robertc Exp $
+ * $Id: HttpRequest.h,v 1.24 2006/09/26 13:30:09 adrian Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
bool parseFirstLine(const char *start, const char *end);
- int parseHeader(const char *parse_start);
+ int parseHeader(const char *parse_start, int len);
virtual bool expectingBody(method_t unused, ssize_t&) const;
/*
- * $Id: client_side.cc,v 1.736 2006/09/25 15:04:06 adrian Exp $
+ * $Id: client_side.cc,v 1.737 2006/09/26 13:30:09 adrian Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
/* compile headers */
/* we should skip request line! */
- if (!request->parseHeader(prefix + req_line_sz)) {
+ /* XXX should actually know the damned buffer size here */
+ if (!request->parseHeader(prefix + req_line_sz, strlen(prefix + req_line_sz))) {
clientStreamNode *node = context->getClientReplyContext();
debug(33, 5) ("Failed to parse request headers:\n%s\n", prefix);
clientReplyContext *repContext = dynamic_cast<clientReplyContext *>(node->data.getRaw());