about summary refs log tree commit homepage
path: root/ext/unicorn/http11/http11_parser.h
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-02-25 12:38:47 -0800
committerEric Wong <normalperson@yhbt.net>2009-02-25 12:39:33 -0800
commitd120ffad9716fbb83806d9755b7b5fd28fdb758b (patch)
tree6c2fde419978edb8d420dbb352c74746626f6fdc /ext/unicorn/http11/http11_parser.h
parent1f29d32cb095cbc21a095772db2fbaf216781f97 (diff)
downloadunicorn-d120ffad9716fbb83806d9755b7b5fd28fdb758b.tar.gz
rename http11 => unicorn/http11
Avoid conflicting with existing (and future) Mongrel installs in
case either changes.  Of course, this also allows us more
freedom to experiment and break the API if needed...
However, I'm only planning on making minor changes to
remove the amount of C code we have to maintain and
possibly some minor performance improvements.
Diffstat (limited to 'ext/unicorn/http11/http11_parser.h')
-rw-r--r--ext/unicorn/http11/http11_parser.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/ext/unicorn/http11/http11_parser.h b/ext/unicorn/http11/http11_parser.h
new file mode 100644
index 0000000..8d074ba
--- /dev/null
+++ b/ext/unicorn/http11/http11_parser.h
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2005 Zed A. Shaw
+ * You can redistribute it and/or modify it under the same terms as Ruby.
+ */
+
+#ifndef http11_parser_h
+#define http11_parser_h
+
+#include <sys/types.h>
+
+#if defined(_WIN32)
+#include <stddef.h>
+#endif
+
+typedef void (*element_cb)(void *data, const char *at, size_t length);
+typedef void (*field_cb)(void *data, const char *field, size_t flen, const char *value, size_t vlen);
+
+typedef struct http_parser {
+  int cs;
+  size_t body_start;
+  int content_len;
+  size_t nread;
+  size_t mark;
+  size_t field_start;
+  size_t field_len;
+  size_t query_start;
+
+  void *data;
+
+  field_cb http_field;
+  element_cb request_method;
+  element_cb request_uri;
+  element_cb fragment;
+  element_cb request_path;
+  element_cb query_string;
+  element_cb http_version;
+  element_cb header_done;
+  
+} http_parser;
+
+int http_parser_init(http_parser *parser);
+int http_parser_finish(http_parser *parser);
+size_t http_parser_execute(http_parser *parser, const char *data, size_t len, size_t off);
+int http_parser_has_error(http_parser *parser);
+int http_parser_is_finished(http_parser *parser);
+
+#define http_parser_nread(parser) (parser)->nread
+
+#endif