From 8a68f2e8216142ecd41d8b020a365065029ffb07 Mon Sep 17 00:00:00 2001 From: evanweaver Date: Thu, 18 Oct 2007 20:45:16 +0000 Subject: java setters are strewn all over the place git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@693 19e92222-5c0b-0410-8929-a290d50e31e9 --- ext/http11_java/org/jruby/mongrel/Http11.java | 12 ++++++++++++ test/test_http11.rb | 1 + 2 files changed, 13 insertions(+) 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 -- cgit v1.2.3-24-ge0c7