src/eui/Makefile
src/format/Makefile
src/http/Makefile
+ src/http/one/Makefile
src/icmp/Makefile
src/ident/Makefile
src/ip/Makefile
#include "globals.h"
#include "gopher.h"
#include "http.h"
-#include "http/Http1Parser.h"
+#include "http/one/RequestParser.h"
#include "HttpHdrCc.h"
#include "HttpHeaderRange.h"
#include "HttpRequest.h"
#include "FwdState.h"
#include "globals.h"
#include "http.h"
-#include "http/Http1Parser.h"
+#include "http/one/RequestParser.h"
#include "HttpHdrContRange.h"
#include "HttpHeaderTools.h"
#include "HttpReply.h"
include $(top_srcdir)/src/Common.am
include $(top_srcdir)/src/TestHeaders.am
+AUTOMAKE_OPTIONS = subdir-objects
+
+SUBDIRS = one
+DIST_SUBDIRS = one
+
noinst_LTLIBRARIES = libsquid-http.la
libsquid_http_la_SOURCES = \
forward.h \
- Http1Parser.cc \
- Http1Parser.h \
MethodType.cc \
MethodType.h \
ProtocolVersion.h \
StatusLine.cc \
StatusLine.h
+libsquid_http_la_LIBADD= one/libhttp1.la
+
MethodType.cc: MethodType.h $(top_srcdir)/src/mk-string-arrays.awk
($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk sbuf=1 < $(srcdir)/MethodType.h | \
sed -e 's%METHOD_%%' -e 's%_C%-C%' >$@) || ($(RM) -f $@ && exit 1)
#ifndef SQUID_SRC_HTTP_FORWARD_H
#define SQUID_SRC_HTTP_FORWARD_H
-#include "base/RefCount.h"
+#include "http/one/forward.h"
// TODO move these classes into Http namespace
class HttpRequestMethod;
class HttpReply;
typedef RefCount<HttpReply> HttpReplyPointer;
-namespace Http {
-
-namespace One {
-class RequestParser;
-typedef RefCount<Http::One::RequestParser> RequestParserPointer;
-} // namespace One
-
-} // namespace Http
-
-namespace Http1 = Http::One;
-
#endif /* SQUID_SRC_HTTP_FORWARD_H */
--- /dev/null
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
+
+noinst_LTLIBRARIES = libhttp1.la
+
+libhttp1_la_SOURCES = \
+ forward.h \
+ Parser.cc \
+ Parser.h \
+ RequestParser.cc \
+ RequestParser.h
--- /dev/null
+#include "squid.h"
+#include "Debug.h"
+#include "http/one/Parser.h"
+
+void
+Http::One::Parser::clear()
+{
+ parsingStage_ = HTTP_PARSE_NONE;
+ buf = NULL;
+ parsedCount_ = 0;
+ msgProtocol_ = AnyP::ProtocolVersion();
+ mimeHeaderBlock_.clear();
+}
+
+// arbitrary maximum-length for headers which can be found by Http1Parser::getHeaderField()
+#define GET_HDR_SZ 1024
+
+char *
+Http::One::Parser::getHeaderField(const char *name)
+{
+ LOCAL_ARRAY(char, header, GET_HDR_SZ);
+ const char *p = NULL;
+ char *q = NULL;
+ char got = 0;
+ const int namelen = name ? strlen(name) : 0;
+
+ if (!headerBlockSize() || !name)
+ return NULL;
+
+ debugs(25, 5, "looking for '" << name << "'");
+
+ for (p = mimeHeader().c_str(); *p; p += strcspn(p, "\n\r")) {
+ if (strcmp(p, "\r\n\r\n") == 0 || strcmp(p, "\n\n") == 0)
+ return NULL;
+
+ while (xisspace(*p))
+ ++p;
+
+ if (strncasecmp(p, name, namelen))
+ continue;
+
+ if (!xisspace(p[namelen]) && p[namelen] != ':')
+ continue;
+
+ int l = strcspn(p, "\n\r") + 1;
+
+ if (l > GET_HDR_SZ)
+ l = GET_HDR_SZ;
+
+ xstrncpy(header, p, l);
+
+ debugs(25, 5, "checking '" << header << "'");
+
+ q = header;
+
+ q += namelen;
+
+ if (*q == ':') {
+ ++q;
+ got = 1;
+ }
+
+ while (xisspace(*q)) {
+ ++q;
+ got = 1;
+ }
+
+ if (got) {
+ debugs(25, 5, "returning '" << q << "'");
+ return q;
+ }
+ }
+
+ return NULL;
+}
#ifndef _SQUID_SRC_HTTP_ONEREQUESTPARSER_H
#define _SQUID_SRC_HTTP_ONEREQUESTPARSER_H
-#include "base/RefCount.h"
-#include "http/forward.h"
-#include "http/ProtocolVersion.h"
-#include "http/RequestMethod.h"
-#include "http/StatusCode.h"
+#include "anyp/ProtocolVersion.h"
+#include "http/one/forward.h"
#include "SBuf.h"
namespace Http {
*/
class Parser : public RefCountable
{
- Parser(const Parser&); // do not implement
+ explicit Parser(const Parser&); // do not implement
Parser& operator =(const Parser&); // do not implement
public:
SBuf mimeHeaderBlock_;
};
-/** HTTP/1.x protocol request parser
- *
- * Works on a raw character I/O buffer and tokenizes the content into
- * the major CRLF delimited segments of an HTTP/1 request message:
- *
- * \item request-line (method, URL, protocol, version)
- * \item mime-header (set of RFC2616 syntax header fields)
- */
-class RequestParser : public Http1::Parser
-{
- RequestParser(const RequestParser&); // do not implement
- RequestParser& operator =(const RequestParser&); // do not implement
-
-public:
- /* Http::One::Parser API */
- RequestParser() : Parser() {}
- virtual ~RequestParser() {}
- virtual void clear();
- virtual int64_t firstLineSize() const {return req.end - req.start + 1;}
- virtual bool parse(const SBuf &aBuf);
-
- /// the HTTP method if this is a request message
- const HttpRequestMethod & method() const {return method_;}
-
- /// the request-line URI if this is a request message, or an empty string.
- const SBuf &requestUri() const {return uri_;}
-
- /** HTTP status code to be used on the invalid-request error page.
- * Http::scNone indicates incomplete parse,
- * Http::scOkay indicates no error.
- */
- Http::StatusCode request_parse_status;
-
-private:
- void skipGarbageLines();
- int parseRequestFirstLine();
-
- /// Offsets for pieces of the (HTTP request) Request-Line as per RFC 2616
- /// only valid before and during parse stage HTTP_PARSE_FIRST
- struct request_offsets {
- int start, end;
- int m_start, m_end; // method
- int u_start, u_end; // url
- int v_start, v_end; // version (full text)
- } req;
-
- /// what request method has been found on the first line
- HttpRequestMethod method_;
-
- /// raw copy of the origina client reqeust-line URI field
- SBuf uri_;
-};
-
} // namespace One
} // namespace Http
#include "squid.h"
#include "Debug.h"
-#include "http/Http1Parser.h"
-#include "http/RequestMethod.h"
+#include "http/one/RequestParser.h"
+#include "http/ProtocolVersion.h"
#include "mime_header.h"
#include "profiler/Profiler.h"
#include "SquidConfig.h"
-void
-Http::One::Parser::clear()
-{
- parsingStage_ = HTTP_PARSE_NONE;
- buf = NULL;
- parsedCount_ = 0;
- msgProtocol_ = AnyP::ProtocolVersion();
- mimeHeaderBlock_.clear();
-}
-
void
Http::One::RequestParser::clear()
{
return !needsMoreData();
}
-
-// arbitrary maximum-length for headers which can be found by Http1Parser::getHeaderField()
-#define GET_HDR_SZ 1024
-
-char *
-Http::One::Parser::getHeaderField(const char *name)
-{
- LOCAL_ARRAY(char, header, GET_HDR_SZ);
- const char *p = NULL;
- char *q = NULL;
- char got = 0;
- const int namelen = name ? strlen(name) : 0;
-
- if (!headerBlockSize() || !name)
- return NULL;
-
- debugs(25, 5, "looking for '" << name << "'");
-
- for (p = mimeHeader().c_str(); *p; p += strcspn(p, "\n\r")) {
- if (strcmp(p, "\r\n\r\n") == 0 || strcmp(p, "\n\n") == 0)
- return NULL;
-
- while (xisspace(*p))
- ++p;
-
- if (strncasecmp(p, name, namelen))
- continue;
-
- if (!xisspace(p[namelen]) && p[namelen] != ':')
- continue;
-
- int l = strcspn(p, "\n\r") + 1;
-
- if (l > GET_HDR_SZ)
- l = GET_HDR_SZ;
-
- xstrncpy(header, p, l);
-
- debugs(25, 5, "checking '" << header << "'");
-
- q = header;
-
- q += namelen;
-
- if (*q == ':') {
- ++q;
- got = 1;
- }
-
- while (xisspace(*q)) {
- ++q;
- got = 1;
- }
-
- if (got) {
- debugs(25, 5, "returning '" << q << "'");
- return q;
- }
- }
-
- return NULL;
-}
--- /dev/null
+#ifndef _SQUID_SRC_HTTP_ONE_REQUESTPARSER_H
+#define _SQUID_SRC_HTTP_ONE_REQUESTPARSER_H
+
+#include "http/one/Parser.h"
+#include "http/RequestMethod.h"
+#include "http/StatusCode.h"
+
+namespace Http {
+namespace One {
+
+/** HTTP/1.x protocol request parser
+ *
+ * Works on a raw character I/O buffer and tokenizes the content into
+ * the major CRLF delimited segments of an HTTP/1 request message:
+ *
+ * \item request-line (method, URL, protocol, version)
+ * \item mime-header (set of RFC2616 syntax header fields)
+ */
+class RequestParser : public Http1::Parser
+{
+ explicit RequestParser(const RequestParser&); // do not implement
+ RequestParser& operator =(const RequestParser&); // do not implement
+
+public:
+ /* Http::One::Parser API */
+ RequestParser() : Parser() {}
+ virtual ~RequestParser() {}
+ virtual void clear();
+ virtual int64_t firstLineSize() const {return req.end - req.start + 1;}
+ virtual bool parse(const SBuf &aBuf);
+
+ /// the HTTP method if this is a request message
+ const HttpRequestMethod & method() const {return method_;}
+
+ /// the request-line URI if this is a request message, or an empty string.
+ const SBuf &requestUri() const {return uri_;}
+
+ /** HTTP status code to be used on the invalid-request error page.
+ * Http::scNone indicates incomplete parse,
+ * Http::scOkay indicates no error.
+ */
+ Http::StatusCode request_parse_status;
+
+private:
+ void skipGarbageLines();
+ int parseRequestFirstLine();
+
+ /// Offsets for pieces of the (HTTP request) Request-Line as per RFC 2616
+ /// only valid before and during parse stage HTTP_PARSE_FIRST
+ struct request_offsets {
+ int start, end;
+ int m_start, m_end; // method
+ int u_start, u_end; // url
+ int v_start, v_end; // version (full text)
+ } req;
+
+ /// what request method has been found on the first line
+ HttpRequestMethod method_;
+
+ /// raw copy of the origina client reqeust-line URI field
+ SBuf uri_;
+};
+
+} // namespace One
+} // namespace Http
+
+#endif /* _SQUID_SRC_HTTP_ONE_REQUESTPARSER_H */
--- /dev/null
+#ifndef SQUID_SRC_HTTP_ONE_FORWARD_H
+#define SQUID_SRC_HTTP_ONE_FORWARD_H
+
+#include "base/RefCount.h"
+
+namespace Http {
+namespace One {
+
+class RequestParser;
+typedef RefCount<Http::One::RequestParser> RequestParserPointer;
+
+} // namespace One
+} // namespace Http
+
+namespace Http1 = Http::One;
+
+#endif /* SQUID_SRC_HTTP_ONE_FORWARD_H */
#define protected public
#include "testHttp1Parser.h"
-#include "http/Http1Parser.h"
+#include "http/one/RequestParser.h"
#include "http/RequestMethod.h"
#include "Mem.h"
#include "MemBuf.h"