#include "squid.h"
#include "Debug.h"
+#include "http/one/Parser.h"
#include "HttpHeaderTools.h"
#include "HttpMsg.h"
#include "MemBuf.h"
return 1;
}
+bool
+HttpMsg::parseHeader(Http1::Parser &hp)
+{
+ // HTTP/1 message contains "zero or more header fields"
+ // zero does not need parsing
+ if (!hp.headerBlockSize()) {
+ pstate = psParsed;
+ return true;
+ }
+
+ // XXX: c_str() reallocates. performance regression.
+ if (header.parse(hp.mimeHeader().c_str(), hp.headerBlockSize())) {
+ pstate = psParsed;
+ hdrCacheInit();
+ return true;
+ }
+
+ pstate = psError;
+ return false;
+}
+
/* handy: resets and returns -1 */
int
HttpMsg::httpMsgParseError()
virtual int httpMsgParseError();
+ // Parser-NG transitional parsing of mime headers
+ bool parseHeader(Http1::Parser &); // TODO move this function to the parser
+
virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const = 0;
void firstLineBuf(MemBuf&);
return true;
}
-bool
-HttpRequest::parseHeader(Http1::RequestParser &hp)
-{
- // HTTP/1 message contains "zero or more header fields"
- // zero does not need parsing
- if (!hp.headerBlockSize())
- return true;
-
- // XXX: c_str() reallocates. performance regression.
- const bool result = header.parse(hp.mimeHeader().c_str(), hp.headerBlockSize());
-
- if (result)
- hdrCacheInit();
-
- return result;
-}
-
/* swaps out request using httpRequestPack */
void
HttpRequest::swapOut(StoreEntry * e)
bool parseFirstLine(const char *start, const char *end);
- bool parseHeader(Http1::RequestParser &hp); // TODO move this function to the parser
-
virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const;
bool bodyNibbled() const; // the request has a [partially] consumed body
newrep->sline.version.minor = hp->messageProtocol().minor;
// parse headers
- newrep->pstate = psReadyToParseHeaders;
- if (newrep->httpMsgParseStep(hp->mimeHeader().rawContent(), hp->mimeHeader().length(), true) < 0) {
+ if (!newrep->parseHeader(*hp)) {
// XXX: when Http::ProtocolVersion is a function, remove this hack. just set with messageProtocol()
newrep->sline.set(Http::ProtocolVersion(), Http::scInvalidHeader);
newrep->sline.version.protocol = hp->messageProtocol().protocol;