about summary refs log tree commit homepage
path: root/ext/http11/http11.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/http11/http11.c')
-rw-r--r--ext/http11/http11.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/http11/http11.c b/ext/http11/http11.c
index 0a0fef7..46a47be 100644
--- a/ext/http11/http11.c
+++ b/ext/http11/http11.c
@@ -25,6 +25,7 @@ static VALUE global_query_string;
 static VALUE global_http_version;
 static VALUE global_content_length;
 static VALUE global_http_content_length;
+static VALUE global_request_path;
 static VALUE global_content_type;
 static VALUE global_http_content_type;
 static VALUE global_gateway_interface;
@@ -53,7 +54,8 @@ static VALUE global_port_80;
 /* Defines the maximum allowed lengths for various input elements.*/
 DEF_MAX_LENGTH(FIELD_NAME, 256);
 DEF_MAX_LENGTH(FIELD_VALUE, 80 * 1024);
-DEF_MAX_LENGTH(REQUEST_URI, 1024);
+DEF_MAX_LENGTH(REQUEST_URI, 1024 * 2);
+DEF_MAX_LENGTH(REQUEST_PATH, 1024);
 DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10));
 DEF_MAX_LENGTH(HEADER, (1024 * (80 + 32)));
 
@@ -103,6 +105,16 @@ void request_uri(void *data, const char *at, size_t length)
   rb_hash_aset(req, global_request_uri, val);
 }
 
+void request_path(void *data, const char *at, size_t length)
+{
+  VALUE req = (VALUE)data;
+  VALUE val = Qnil;
+
+  VALIDATE_MAX_LENGTH(length, REQUEST_PATH);
+
+  val = rb_str_new(at, length);
+  rb_hash_aset(req, global_request_path, val);
+}
 
 void query_string(void *data, const char *at, size_t length)
 {
@@ -182,6 +194,7 @@ VALUE HttpParser_alloc(VALUE klass)
   hp->http_field = http_field;
   hp->request_method = request_method;
   hp->request_uri = request_uri;
+  hp->request_path = request_path;
   hp->query_string = query_string;
   hp->http_version = http_version;
   hp->header_done = header_done;
@@ -531,6 +544,7 @@ void Init_http11()
   DEF_GLOBAL(request_uri, "REQUEST_URI");
   DEF_GLOBAL(query_string, "QUERY_STRING");
   DEF_GLOBAL(http_version, "HTTP_VERSION");
+  DEF_GLOBAL(request_path, "REQUEST_PATH");
   DEF_GLOBAL(content_length, "CONTENT_LENGTH");
   DEF_GLOBAL(http_content_length, "HTTP_CONTENT_LENGTH");
   DEF_GLOBAL(content_type, "CONTENT_TYPE");