/*
- * $Id: HttpMsg.cc,v 1.18 2005/09/17 04:53:44 wessels Exp $
+ * $Id: HttpMsg.cc,v 1.19 2005/11/07 22:00:38 wessels Exp $
*
* DEBUG: section 74 HTTP Message
* AUTHOR: Alex Rousskov
return true;
}
-
+/*
+ * parse() takes character buffer of HTTP headers (buf),
+ * which may not be NULL-terminated, and fills in an HttpMsg
+ * structure. The parameter 'end' specifies the offset to
+ * the end of the reply headers. The caller may know where the
+ * end is, but is unable to NULL-terminate the buffer. This function
+ * returns true on success.
+ */
+bool
+HttpMsg::parseCharBuf(const char *buf, ssize_t end)
+{
+ MemBuf mb;
+ int success;
+ /* reset current state, because we are not used in incremental fashion */
+ reset();
+ mb.init();
+ mb.append(buf, end);
+ mb.terminate();
+ success = httpMsgParseStep(mb.buf, 0);
+ mb.clean();
+ return success == 1;
+}
/*
* parses a 0-terminating buffer into HttpMsg.
/*
- * $Id: HttpMsg.h,v 1.3 2005/09/15 20:19:41 wessels Exp $
+ * $Id: HttpMsg.h,v 1.4 2005/11/07 22:00:38 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
HttpMsgParseState pstate; /* the current parsing state */
bool parse(MemBuf *buf, bool eol, http_status *error);
+ bool parseCharBuf(const char *buf, ssize_t end);
int httpMsgParseStep(const char *buf, int atEnd);
int httpMsgParseError();
/*
- * $Id: HttpReply.cc,v 1.78 2005/11/05 00:08:32 wessels Exp $
+ * $Id: HttpReply.cc,v 1.79 2005/11/07 22:00:38 wessels Exp $
*
* DEBUG: section 58 HTTP Reply (Response)
* AUTHOR: Alex Rousskov
delete new_rep;
}
-/*
- * parse() takes character buffer of HTTP headers (buf),
- * which may not be NULL-terminated, and fills in an HttpReply
- * structure (rep). The parameter 'end' specifies the offset to
- * the end of the reply headers. The caller may know where the
- * end is, but is unable to NULL-terminate the buffer. This function
- * returns true on success.
- */
-bool
-HttpReply::parse(const char *buf, ssize_t end)
-{
- /*
- * this extra buffer/copy will be eliminated when headers become
- * meta-data in store. Currently we have to xstrncpy the buffer
- * becuase somebody may feed a non NULL-terminated buffer to
- * us.
- */
- MemBuf mb;
- int success;
- /* reset current state, because we are not used in incremental fashion */
- reset();
- /* put a string terminator. s is how many bytes to touch in
- * 'buf' including the terminating NULL. */
- mb.init();
- mb.append(buf, end);
- mb.terminate();
- success = httpMsgParseStep(mb.buf, 0);
- mb.clean();
- return success == 1;
-}
-
void
HttpReply::packHeadersInto(Packer * p) const
{
/*
- * $Id: HttpReply.h,v 1.12 2005/11/05 00:08:32 wessels Exp $
+ * $Id: HttpReply.h,v 1.13 2005/11/07 22:00:38 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
public:
void updateOnNotModified(HttpReply const *other);
- /* parse returns true on success */
- bool parse(const char *buf, ssize_t);
/* absorb: copy the contents of a new reply to the old one, destroy new one */
void absorb(HttpReply * new_rep);
/* set commonly used info with one call */
/*
- * $Id: client_side_reply.cc,v 1.89 2005/11/05 00:08:32 wessels Exp $
+ * $Id: client_side_reply.cc,v 1.90 2005/11/07 22:00:38 wessels Exp $
*
* DEBUG: section 88 Client-side Reply Routines
* AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
holdReply(new HttpReply);
- if (!holdingReply->parse(buf, k)) {
+ if (!holdingReply->parseCharBuf(buf, k)) {
/* parsing failure, get rid of the invalid reply */
delete holdingReply;
holdReply (NULL);
/*
- * $Id: http.cc,v 1.465 2005/11/05 00:08:32 wessels Exp $
+ * $Id: http.cc,v 1.466 2005/11/07 22:00:38 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
/* Parse headers into reply structure */
/* what happens if we fail to parse here? */
- reply->parse(reply_hdr.buf, hdr_size);
+ reply->parseCharBuf(reply_hdr.buf, hdr_size);
if (reply->sline.status >= HTTP_INVALID_HEADER) {
debugs(11, 3, "processReplyHeader: Non-HTTP-compliant header: '" << reply_hdr.buf << "'");
/*
- * $Id: store_client.cc,v 1.143 2005/11/05 00:08:33 wessels Exp $
+ * $Id: store_client.cc,v 1.144 2005/11/07 22:00:38 wessels Exp $
*
* DEBUG: section 90 Storage Manager Client-Side Interface
* AUTHOR: Duane Wessels
/* Our structure ! */
HttpReply *rep = (HttpReply *) sc->entry->getReply(); // bypass const
- if (!rep->parse(sc->copyInto.data, headersEnd(sc->copyInto.data, len))) {
+ if (!rep->parseCharBuf(sc->copyInto.data, headersEnd(sc->copyInto.data, len))) {
debug (90,0)("Could not parse headers from on disk object\n");
}
}
/* Our structure ! */
HttpReply *rep = (HttpReply *) entry->getReply(); // bypass const
- if (!rep->parse(copyInto.data, headersEnd(copyInto.data, copy_sz))) {
+ if (!rep->parseCharBuf(copyInto.data, headersEnd(copyInto.data, copy_sz))) {
debug (90,0)("could not parse headers from on disk structure!\n");
}
}
/*
- * $Id: urn.cc,v 1.91 2005/11/05 00:08:33 wessels Exp $
+ * $Id: urn.cc,v 1.92 2005/11/07 22:00:38 wessels Exp $
*
* DEBUG: section 52 URN Parsing
* AUTHOR: Kostas Anagnostakis
s = buf + k;
assert(urlres_e->getReply());
rep = new HttpReply;
- rep->parse(buf, k);
+ rep->parseCharBuf(buf, k);
debug(52, 3) ("reply exists, code=%d.\n",
rep->sline.status);