/*
- * $Id: HttpMsg.cc,v 1.34 2006/09/27 13:17:52 adrian Exp $
+ * $Id: HttpMsg.cc,v 1.35 2006/09/27 13:47:53 adrian Exp $
*
* DEBUG: section 74 HTTP Message
* AUTHOR: Alex Rousskov
hdr->hdr_start = hdr->hdr_end = -1;
}
+#if MSGDODEBUG
/* XXX This should eventually turn into something inlined or #define'd */
int
HttpParserReqSz(HttpParser *hp)
{
return hp->hdr_end - hp->req_start + 1;
}
+#endif
/*
* Attempt to parse the request line.
int maj = -1, min = -1;
int last_whitespace = -1, line_end = -1;
+ PROF_start(HttpParserParseReqLine);
/* Find \r\n - end of URL+Version (and the request) */
for (i = 0; i < hmsg->bufsiz; i++) {
if (hmsg->buf[i] == '\n') {
hmsg->v_min = min;
assert(maj != -1);
assert(min != -1);
+ PROF_stop(HttpParserParseReqLine);
debug(1, 2) ("Parser: retval %d: from %d->%d: method %d->%d; url %d->%d; version %d->%d (%d/%d)\n",
retcode, hmsg->req_start, hmsg->req_end,
hmsg->m_start, hmsg->m_end,
/*
- * $Id: HttpMsg.h,v 1.12 2006/09/27 13:17:52 adrian Exp $
+ * $Id: HttpMsg.h,v 1.13 2006/09/27 13:47:53 adrian Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
typedef struct _HttpParser HttpParser;
extern void HttpParserInit(HttpParser *, const char *buf, int len);
+extern int HttpParserParseReqLine(HttpParser *hp);
+
+#if MSGDODEBUG
extern int HttpParserReqSz(HttpParser *);
extern int HttpParserHdrSz(HttpParser *);
extern const char * HttpParserHdrBuf(HttpParser *);
extern int HttpParserRequestLen(HttpParser *hp);
-extern int HttpParserParseReqLine(HttpParser *hp);
+#else
+#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
SQUIDCEXTERN int httpMsgIsolateHeaders(const char **parse_start, int len, const char **blk_start, const char **blk_end);
/*
- * $Id: client_side.cc,v 1.739 2006/09/27 13:17:52 adrian Exp $
+ * $Id: client_side.cc,v 1.740 2006/09/27 13:47:53 adrian Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
/* Request line is valid here .. */
*http_ver = HttpVersion(hp->v_maj, hp->v_min);
+ /* This call scans the entire request, not just the headers */
if (hp->v_maj > 0) {
if ((req_sz = headersEnd(hp->buf, hp->bufsiz)) == 0) {
debug(33, 5) ("Incomplete request, waiting for end of headers\n");
req_sz = HttpParserReqSz(hp);
}
+ /* We know the whole request is in hp->buf now */
+
assert(req_sz <= (size_t) hp->bufsiz);
/* Will the following be true with HTTP/0.9 requests? probably not .. */
/* So the rest of the code will need to deal with '0'-byte headers (ie, none, so don't try parsing em) */
*/
/* XXX this code should be modified to take a const char * later! */
req_hdr = (char *) hp->buf + hp->req_end + 1;
-
debug(33, 3) ("parseHttpRequest: req_hdr = {%s}\n", req_hdr);
-
- end = req_hdr + HttpParserHdrSz(hp);
-
+ end = (char *) hp->buf + hp->hdr_end;
debug(33, 3) ("parseHttpRequest: end = {%s}\n", end);
if (strstr(req_hdr, "\r\r\n")) {
debug(33, 3) ("parseHttpRequest: prefix_sz = %d, req_line_sz = %d\n",
(int) HttpParserRequestLen(hp), HttpParserReqSz(hp));
- assert((size_t) HttpParserRequestLen(hp) <= (size_t) hp->bufsiz);
-
/* Ok, all headers are received */
http = new ClientHttpRequest(conn);
http->req_sz = HttpParserRequestLen(hp);
-
result = ClientSocketContextNew(http);
-
tempBuffer.data = result->reqbuf;
-
tempBuffer.length = HTTP_REQBUF_SZ;
ClientStreamData newServer = new clientReplyContext(http);
-
ClientStreamData newClient = result;
-
clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
clientReplyStatus, newServer, clientSocketRecipient,
clientSocketDetach, newClient, tempBuffer);