about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2007-10-18 20:45:16 +0000
committerevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2007-10-18 20:45:16 +0000
commit8a68f2e8216142ecd41d8b020a365065029ffb07 (patch)
tree0f04595aae3449a61e44a0063df8fc4150ed7eca
parent98d65e6da03dd65fc21c16c1b6992f13c7681af9 (diff)
downloadunicorn-8a68f2e8216142ecd41d8b020a365065029ffb07.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@693 19e92222-5c0b-0410-8929-a290d50e31e9
-rw-r--r--ext/http11_java/org/jruby/mongrel/Http11.java12
-rw-r--r--test/test_http11.rb1
2 files changed, 13 insertions, 0 deletions
diff --git a/ext/http11_java/org/jruby/mongrel/Http11.java b/ext/http11_java/org/jruby/mongrel/Http11.java
index fff8b41..a73c79b 100644
--- a/ext/http11_java/org/jruby/mongrel/Http11.java
+++ b/ext/http11_java/org/jruby/mongrel/Http11.java
@@ -53,6 +53,8 @@ public class Http11 extends RubyObject {
     public final static String MAX_FIELD_VALUE_LENGTH_ERR = "HTTP element FIELD_VALUE is longer than the 81920 allowed length.";
     public final static int MAX_REQUEST_URI_LENGTH = 1024 * 12;
     public final static String MAX_REQUEST_URI_LENGTH_ERR = "HTTP element REQUEST_URI is longer than the 12288 allowed length.";
+    public final static int MAX_FRAGMENT_LENGTH = 1024;
+    public final static String MAX_FRAGMENT_LENGTH_ERR = "HTTP element REQUEST_PATH is longer than the 1024 allowed length.";
     public final static int MAX_REQUEST_PATH_LENGTH = 1024;
     public final static String MAX_REQUEST_PATH_LENGTH_ERR = "HTTP element REQUEST_PATH is longer than the 1024 allowed length.";
     public final static int MAX_QUERY_STRING_LENGTH = 1024 * 10;
@@ -97,6 +99,7 @@ public class Http11 extends RubyObject {
         this.hp.parser.http_field = http_field;
         this.hp.parser.request_method = request_method;
         this.hp.parser.request_uri = request_uri;
+        this.hp.parser.fragment = fragment;
         this.hp.parser.request_path = request_path;
         this.hp.parser.query_string = query_string;
         this.hp.parser.http_version = http_version;
@@ -149,6 +152,15 @@ public class Http11 extends RubyObject {
             }
         };
 
+    private Http11Parser.ElementCB fragment = new Http11Parser.ElementCB() {
+            public void call(Object data, int at, int length) {
+                RubyHash req = (RubyHash)data;
+                validateMaxLength(length, MAX_FRAGMENT_LENGTH, MAX_FRAGMENT_LENGTH_ERR);
+                RubyString val = RubyString.newString(runtime,new ByteList(hp.parser.buffer,at,length));
+                req.aset(runtime.newString("FRAGMENT"),val);
+            }
+        };
+
     private Http11Parser.ElementCB request_path = new Http11Parser.ElementCB() {
             public void call(Object data, int at, int length) {
                 RubyHash req = (RubyHash)data;
diff --git a/test/test_http11.rb b/test/test_http11.rb
index 3afa8c1..11d0bc3 100644
--- a/test/test_http11.rb
+++ b/test/test_http11.rb
@@ -81,6 +81,7 @@ class HttpParserTest < Test::Unit::TestCase
       parser.execute(req, get, 0)
     end
     assert parser.finished?
+    assert_equal '/forums/1/topics/2375?page=1', req['REQUEST_URI']
     assert_equal 'posts-17408', req['FRAGMENT']
   end