From 66254b6f2b0ebb3899413b12d96614ac9318daae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 4 Feb 2009 14:03:13 -0800 Subject: Remove Java and Win32 support Supporting corporate enterprise platforms isn't my style :P Signed-off-by: Eric Wong --- Manifest | 4 - Rakefile | 67 +-- ext/http11/http11_parser.java.rl | 171 -------- ext/http11_java/Http11Service.java | 13 - ext/http11_java/org/jruby/mongrel/Http11.java | 266 ------------ .../org/jruby/mongrel/Http11Parser.java | 474 --------------------- 6 files changed, 3 insertions(+), 992 deletions(-) delete mode 100644 ext/http11/http11_parser.java.rl delete mode 100644 ext/http11_java/Http11Service.java delete mode 100644 ext/http11_java/org/jruby/mongrel/Http11.java delete mode 100644 ext/http11_java/org/jruby/mongrel/Http11Parser.java diff --git a/Manifest b/Manifest index bc3c7f1..b91a692 100644 --- a/Manifest +++ b/Manifest @@ -7,12 +7,8 @@ ext/http11/extconf.rb ext/http11/http11.c ext/http11/http11_parser.c ext/http11/http11_parser.h -ext/http11/http11_parser.java.rl ext/http11/http11_parser.rl ext/http11/http11_parser_common.rl -ext/http11_java/Http11Service.java -ext/http11_java/org/jruby/mongrel/Http11.java -ext/http11_java/org/jruby/mongrel/Http11Parser.java lib/mongrel/cgi.rb lib/mongrel/const.rb lib/mongrel/handlers.rb diff --git a/Rakefile b/Rakefile index a0d91a0..0f9dd15 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,7 @@ Echoe.new("mongrel") do |p| p.summary = "A small fast HTTP library and server for Rack applications." p.author = "Evan Weaver" p.email = "evan@cloudbur.st" - p.clean_pattern = ['ext/http11/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'lib/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'ext/http11/Makefile', 'pkg', 'lib/*.bundle', '*.gem', 'site/output', '.config', 'lib/http11.jar', 'ext/http11_java/classes', 'coverage', 'test_*.log', 'log', 'doc'] + p.clean_pattern = ['ext/http11/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'lib/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'ext/http11/Makefile', 'pkg', 'lib/*.bundle', '*.gem', 'site/output', '.config', 'coverage', 'test_*.log', 'log', 'doc'] p.url = "http://mongrel.rubyforge.org" p.rdoc_pattern = ['README', 'LICENSE', 'CONTRIBUTORS', 'CHANGELOG', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc'] p.docs_host = 'mongrel.cloudbur.st:/home/eweaver/www/mongrel/htdocs/web' @@ -26,20 +26,10 @@ Echoe.new("mongrel") do |p| p.need_tar_gz = false p.need_tgz = true - unless Platform.windows? or Platform.java? - p.extension_pattern = ["ext/**/extconf.rb"] - end + p.extension_pattern = ["ext/**/extconf.rb"] p.eval = proc do - if Platform.windows? - self.files += ['lib/http11.so'] - self.platform = Gem::Platform::CURRENT - elsif Platform.java? - self.files += ['lib/http11.jar'] - self.platform = 'jruby' # XXX Is this right? - else - add_dependency('daemons', '>= 1.0.3') - end + add_dependency('daemons', '>= 1.0.3') end end @@ -54,12 +44,6 @@ task :ragel do sh "ragel http11_parser.rl -C -G2 -o #{target}" raise "Failed to build C source" unless File.exist? target end - Dir.chdir "ext/http11" do - target = "../../ext/http11_java/org/jruby/mongrel/Http11Parser.java" - File.unlink target if File.exist? target - sh "ragel http11_parser.rl -J -o #{target}" - raise "Failed to build Java source" unless File.exist? target - end end #### Pre-compiled extensions for alternative platforms @@ -67,48 +51,3 @@ end def move_extensions Dir["ext/**/*.#{Config::CONFIG['DLEXT']}"].each { |file| mv file, "lib/" } end - -def java_classpath_arg - # A myriad of ways to discover the JRuby classpath - classpath = begin - require 'java' - # Already running in a JRuby JVM - Java::java.lang.System.getProperty('java.class.path') - rescue LoadError - ENV['JRUBY_PARENT_CLASSPATH'] || ENV['JRUBY_HOME'] && FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR) - end - classpath ? "-cp #{classpath}" : "" -end - -if Platform.windows? - filename = "lib/http11.so" - file filename do - Dir.chdir("ext/http11") do - ruby "extconf.rb" - system(Platform.make) - end - move_extensions - end - task :compile => [filename] - -elsif Platform.java? - - # Avoid JRuby in-process launching problem - begin - require 'jruby' - JRuby.runtime.instance_config.run_ruby_in_process = false - rescue LoadError - end - - filename = "lib/http11.jar" - file filename do - build_dir = "ext/http11_java/classes" - mkdir_p build_dir - sources = FileList['ext/http11_java/**/*.java'].join(' ') - sh "javac -target 1.4 -source 1.4 -d #{build_dir} #{java_classpath_arg} #{sources}" - sh "jar cf lib/http11.jar -C #{build_dir} ." - move_extensions - end - task :compile => [filename] - -end diff --git a/ext/http11/http11_parser.java.rl b/ext/http11/http11_parser.java.rl deleted file mode 100644 index c9be22e..0000000 --- a/ext/http11/http11_parser.java.rl +++ /dev/null @@ -1,171 +0,0 @@ -package org.jruby.mongrel; - -import org.jruby.util.ByteList; - -public class Http11Parser { - -/** Machine **/ - -%%{ - - machine http_parser; - - action mark {parser.mark = fpc; } - - action start_field { parser.field_start = fpc; } - action snake_upcase_field { /* FIXME stub */ } - action write_field { - parser.field_len = fpc-parser.field_start; - } - - action start_value { parser.mark = fpc; } - action write_value { - if(parser.http_field != null) { - parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, fpc-parser.mark); - } - } - action request_method { - if(parser.request_method != null) - parser.request_method.call(parser.data, parser.mark, fpc-parser.mark); - } - action request_uri { - if(parser.request_uri != null) - parser.request_uri.call(parser.data, parser.mark, fpc-parser.mark); - } - action fragment { - if(parser.fragment != null) - parser.fragment.call(parser.data, parser.mark, fpc-parser.mark); - } - - action start_query {parser.query_start = fpc; } - action query_string { - if(parser.query_string != null) - parser.query_string.call(parser.data, parser.query_start, fpc-parser.query_start); - } - - action http_version { - if(parser.http_version != null) - parser.http_version.call(parser.data, parser.mark, fpc-parser.mark); - } - - action request_path { - if(parser.request_path != null) - parser.request_path.call(parser.data, parser.mark, fpc-parser.mark); - } - - action done { - parser.body_start = fpc + 1; - if(parser.header_done != null) - parser.header_done.call(parser.data, fpc + 1, pe - fpc - 1); - fbreak; - } - - include http_parser_common "http11_parser_common.rl"; - -}%% - -/** Data **/ -%% write data; - - public static interface ElementCB { - public void call(Object data, int at, int length); - } - - public static interface FieldCB { - public void call(Object data, int field, int flen, int value, int vlen); - } - - public static class HttpParser { - int cs; - int body_start; - int content_len; - int nread; - int mark; - int field_start; - int field_len; - int query_start; - - Object data; - ByteList buffer; - - public FieldCB http_field; - public ElementCB request_method; - public ElementCB request_uri; - public ElementCB fragment; - public ElementCB request_path; - public ElementCB query_string; - public ElementCB http_version; - public ElementCB header_done; - - public void init() { - cs = 0; - - %% write init; - - body_start = 0; - content_len = 0; - mark = 0; - nread = 0; - field_len = 0; - field_start = 0; - } - } - - public final HttpParser parser = new HttpParser(); - - public int execute(ByteList buffer, int off) { - int p, pe; - int cs = parser.cs; - int len = buffer.realSize; - assert off<=len : "offset past end of buffer"; - - p = off; - pe = len; - byte[] data = buffer.bytes; - parser.buffer = buffer; - - %% write exec; - - parser.cs = cs; - parser.nread += (p - off); - - assert p <= pe : "buffer overflow after parsing execute"; - assert parser.nread <= len : "nread longer than length"; - assert parser.body_start <= len : "body starts after buffer end"; - assert parser.mark < len : "mark is after buffer end"; - assert parser.field_len <= len : "field has length longer than whole buffer"; - assert parser.field_start < len : "field starts after buffer end"; - - if(parser.body_start>0) { - /* final \r\n combo encountered so stop right here */ - %%write eof; - parser.nread++; - } - - return parser.nread; - } - - public int finish() { - int cs = parser.cs; - - %%write eof; - - parser.cs = cs; - - if(has_error()) { - return -1; - } else if(is_finished()) { - return 1; - } else { - return 0; - } - } - - public boolean has_error() { - return parser.cs == http_parser_error; - } - - public boolean is_finished() { - return parser.cs == http_parser_first_final; - } -} diff --git a/ext/http11_java/Http11Service.java b/ext/http11_java/Http11Service.java deleted file mode 100644 index 5d78c49..0000000 --- a/ext/http11_java/Http11Service.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.io.IOException; - -import org.jruby.Ruby; -import org.jruby.runtime.load.BasicLibraryService; - -import org.jruby.mongrel.Http11; - -public class Http11Service implements BasicLibraryService { - public boolean basicLoad(final Ruby runtime) throws IOException { - Http11.createHttp11(runtime); - return true; - } -} diff --git a/ext/http11_java/org/jruby/mongrel/Http11.java b/ext/http11_java/org/jruby/mongrel/Http11.java deleted file mode 100644 index 4ab5c7f..0000000 --- a/ext/http11_java/org/jruby/mongrel/Http11.java +++ /dev/null @@ -1,266 +0,0 @@ -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Ola Bini - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby.mongrel; - -import org.jruby.Ruby; -import org.jruby.RubyClass; -import org.jruby.RubyHash; -import org.jruby.RubyModule; -import org.jruby.RubyNumeric; -import org.jruby.RubyObject; -import org.jruby.RubyString; - -import org.jruby.runtime.CallbackFactory; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.builtin.IRubyObject; - -import org.jruby.exceptions.RaiseException; - -import org.jruby.util.ByteList; - -/** - * @author Ola Bini - */ -public class Http11 extends RubyObject { - public final static int MAX_FIELD_NAME_LENGTH = 256; - public final static String MAX_FIELD_NAME_LENGTH_ERR = "HTTP element FIELD_NAME is longer than the 256 allowed length."; - public final static int MAX_FIELD_VALUE_LENGTH = 80 * 1024; - 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; - public final static String MAX_QUERY_STRING_LENGTH_ERR = "HTTP element QUERY_STRING is longer than the 10240 allowed length."; - public final static int MAX_HEADER_LENGTH = 1024 * (80 + 32); - public final static String MAX_HEADER_LENGTH_ERR = "HTTP element HEADER is longer than the 114688 allowed length."; - - - private static ObjectAllocator ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new Http11(runtime, klass); - } - }; - - public static void createHttp11(Ruby runtime) { - RubyModule mMongrel = runtime.defineModule("Mongrel"); - mMongrel.defineClassUnder("HttpParserError",runtime.getClass("IOError"),runtime.getClass("IOError").getAllocator()); - - CallbackFactory cf = runtime.callbackFactory(Http11.class); - - RubyClass cHttpParser = mMongrel.defineClassUnder("HttpParser",runtime.getObject(),ALLOCATOR); - cHttpParser.defineFastMethod("initialize",cf.getFastMethod("initialize")); - cHttpParser.defineFastMethod("reset",cf.getFastMethod("reset")); - cHttpParser.defineFastMethod("finish",cf.getFastMethod("finish")); - cHttpParser.defineFastMethod("execute",cf.getFastMethod("execute", IRubyObject.class, IRubyObject.class, IRubyObject.class)); - cHttpParser.defineFastMethod("error?",cf.getFastMethod("has_error")); - cHttpParser.defineFastMethod("finished?",cf.getFastMethod("is_finished")); - cHttpParser.defineFastMethod("nread",cf.getFastMethod("nread")); - } - - private Ruby runtime; - private RubyClass eHttpParserError; - private Http11Parser hp; - - public Http11(Ruby runtime, RubyClass clazz) { - super(runtime,clazz); - this.runtime = runtime; - this.eHttpParserError = (RubyClass)runtime.getModule("Mongrel").getConstant("HttpParserError"); - this.hp = new Http11Parser(); - 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; - this.hp.parser.header_done = header_done; - this.hp.parser.init(); - } - - public void validateMaxLength(int len, int max, String msg) { - if(len>max) { - throw new RaiseException(runtime, eHttpParserError, msg, true); - } - } - - private Http11Parser.FieldCB http_field = new Http11Parser.FieldCB() { - public void call(Object data, int field, int flen, int value, int vlen) { - RubyHash req = (RubyHash)data; - RubyString v,f; - validateMaxLength(flen, MAX_FIELD_NAME_LENGTH, MAX_FIELD_NAME_LENGTH_ERR); - validateMaxLength(vlen, MAX_FIELD_VALUE_LENGTH, MAX_FIELD_VALUE_LENGTH_ERR); - - v = RubyString.newString(runtime, new ByteList(Http11.this.hp.parser.buffer,value,vlen)); - f = RubyString.newString(runtime, "HTTP_"); - ByteList b = new ByteList(Http11.this.hp.parser.buffer,field,flen); - for(int i=0,j=b.realSize;i= d.realSize) { - throw new RaiseException(runtime, eHttpParserError, "Requested start is after data buffer end.", true); - } else { - this.hp.parser.data = req_hash; - this.hp.execute(d,from); - validateMaxLength(this.hp.parser.nread,MAX_HEADER_LENGTH, MAX_HEADER_LENGTH_ERR); - if(this.hp.has_error()) { - throw new RaiseException(runtime, eHttpParserError, "Invalid HTTP format, parsing fails.", true); - } else { - return runtime.newFixnum((long)this.hp.parser.nread); - } - } - } - - public IRubyObject has_error() { - return this.hp.has_error() ? runtime.getTrue() : runtime.getFalse(); - } - - public IRubyObject is_finished() { - return this.hp.is_finished() ? runtime.getTrue() : runtime.getFalse(); - } - - public IRubyObject nread() { - return runtime.newFixnum(this.hp.parser.nread); - } -}// Http11 diff --git a/ext/http11_java/org/jruby/mongrel/Http11Parser.java b/ext/http11_java/org/jruby/mongrel/Http11Parser.java deleted file mode 100644 index 2dd0078..0000000 --- a/ext/http11_java/org/jruby/mongrel/Http11Parser.java +++ /dev/null @@ -1,474 +0,0 @@ -// line 1 "http11_parser.rl" -/** - * Copyright (c) 2005 Zed A. Shaw - * You can redistribute it and/or modify it under the same terms as Ruby. - */ -#include "http11_parser.h" -#include -#include -#include -#include -#include - -/* - * capitalizes all lower-case ASCII characters, - * converts dashes to underscores. - */ -static void snake_upcase_char(char *c) -{ - if (*c >= 'a' && *c <= 'z') - *c &= ~0x20; - else if (*c == '-') - *c = '_'; -} - -#define LEN(AT, FPC) (FPC - buffer - parser->AT) -#define MARK(M,FPC) (parser->M = (FPC) - buffer) -#define PTR_TO(F) (buffer + parser->F) - -/** Machine **/ - -// line 87 "http11_parser.rl" - - -/** Data **/ - -// line 37 "../../ext/http11_java/org/jruby/mongrel/Http11Parser.java" -private static byte[] init__http_parser_actions_0() -{ - return new byte [] { - 0, 1, 0, 1, 2, 1, 3, 1, 4, 1, 5, 1, - 6, 1, 7, 1, 8, 1, 9, 1, 11, 1, 12, 1, - 13, 2, 0, 8, 2, 1, 2, 2, 4, 5, 2, 10, - 7, 2, 12, 7, 3, 9, 10, 7 - }; -} - -private static final byte _http_parser_actions[] = init__http_parser_actions_0(); - - -private static short[] init__http_parser_key_offsets_0() -{ - return new short [] { - 0, 0, 8, 17, 27, 29, 30, 31, 32, 33, 34, 36, - 39, 41, 44, 45, 61, 62, 78, 80, 81, 90, 99, 105, - 111, 121, 130, 136, 142, 153, 159, 165, 175, 181, 187, 196, - 205, 211, 217, 226, 235, 244, 253, 262, 271, 280, 289, 298, - 307, 316, 325, 334, 343, 352, 361, 370, 379, 380 - }; -} - -private static final short _http_parser_key_offsets[] = init__http_parser_key_offsets_0(); - - -private static char[] init__http_parser_trans_keys_0() -{ - return new char [] { - 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, - 46, 48, 57, 65, 90, 42, 43, 47, 58, 45, 57, 65, - 90, 97, 122, 32, 35, 72, 84, 84, 80, 47, 48, 57, - 46, 48, 57, 48, 57, 13, 48, 57, 10, 13, 33, 124, - 126, 35, 39, 42, 43, 45, 46, 48, 57, 65, 90, 94, - 122, 10, 33, 58, 124, 126, 35, 39, 42, 43, 45, 46, - 48, 57, 65, 90, 94, 122, 13, 32, 13, 32, 37, 60, - 62, 127, 0, 31, 34, 35, 32, 37, 60, 62, 127, 0, - 31, 34, 35, 48, 57, 65, 70, 97, 102, 48, 57, 65, - 70, 97, 102, 43, 58, 45, 46, 48, 57, 65, 90, 97, - 122, 32, 34, 35, 37, 60, 62, 127, 0, 31, 48, 57, - 65, 70, 97, 102, 48, 57, 65, 70, 97, 102, 32, 34, - 35, 37, 59, 60, 62, 63, 127, 0, 31, 48, 57, 65, - 70, 97, 102, 48, 57, 65, 70, 97, 102, 32, 34, 35, - 37, 60, 62, 63, 127, 0, 31, 48, 57, 65, 70, 97, - 102, 48, 57, 65, 70, 97, 102, 32, 34, 35, 37, 60, - 62, 127, 0, 31, 32, 34, 35, 37, 60, 62, 127, 0, - 31, 48, 57, 65, 70, 97, 102, 48, 57, 65, 70, 97, - 102, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, - 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, - 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, - 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, - 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, - 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, - 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, - 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, - 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, - 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, - 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, - 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, - 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, - 95, 45, 46, 48, 57, 65, 90, 32, 0 - }; -} - -private static final char _http_parser_trans_keys[] = init__http_parser_trans_keys_0(); - - -private static byte[] init__http_parser_single_lengths_0() -{ - return new byte [] { - 0, 2, 3, 4, 2, 1, 1, 1, 1, 1, 0, 1, - 0, 1, 1, 4, 1, 4, 2, 1, 5, 5, 0, 0, - 2, 7, 0, 0, 9, 0, 0, 8, 0, 0, 7, 7, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 1, 0 - }; -} - -private static final byte _http_parser_single_lengths[] = init__http_parser_single_lengths_0(); - - -private static byte[] init__http_parser_range_lengths_0() -{ - return new byte [] { - 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 0, 6, 0, 6, 0, 0, 2, 2, 3, 3, - 4, 1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 1, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 0, 0 - }; -} - -private static final byte _http_parser_range_lengths[] = init__http_parser_range_lengths_0(); - - -private static short[] init__http_parser_index_offsets_0() -{ - return new short [] { - 0, 0, 6, 13, 21, 24, 26, 28, 30, 32, 34, 36, - 39, 41, 44, 46, 57, 59, 70, 73, 75, 83, 91, 95, - 99, 106, 115, 119, 123, 134, 138, 142, 152, 156, 160, 169, - 178, 182, 186, 193, 200, 207, 214, 221, 228, 235, 242, 249, - 256, 263, 270, 277, 284, 291, 298, 305, 312, 314 - }; -} - -private static final short _http_parser_index_offsets[] = init__http_parser_index_offsets_0(); - - -private static byte[] init__http_parser_indicies_0() -{ - return new byte [] { - 0, 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 3, - 1, 4, 5, 6, 7, 5, 5, 5, 1, 8, 9, 1, - 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, - 16, 15, 1, 17, 1, 18, 17, 1, 19, 1, 20, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 1, 22, 1, 23, - 24, 23, 23, 23, 23, 23, 23, 23, 23, 1, 26, 27, - 25, 29, 28, 30, 32, 1, 1, 1, 1, 1, 31, 33, - 35, 1, 1, 1, 1, 1, 34, 36, 36, 36, 1, 34, - 34, 34, 1, 37, 38, 37, 37, 37, 37, 1, 8, 1, - 9, 39, 1, 1, 1, 1, 38, 40, 40, 40, 1, 38, - 38, 38, 1, 41, 1, 43, 44, 45, 1, 1, 46, 1, - 1, 42, 47, 47, 47, 1, 42, 42, 42, 1, 8, 1, - 9, 49, 1, 1, 50, 1, 1, 48, 51, 51, 51, 1, - 48, 48, 48, 1, 52, 1, 54, 55, 1, 1, 1, 1, - 53, 56, 1, 58, 59, 1, 1, 1, 1, 57, 60, 60, - 60, 1, 57, 57, 57, 1, 2, 61, 61, 61, 61, 61, - 1, 2, 62, 62, 62, 62, 62, 1, 2, 63, 63, 63, - 63, 63, 1, 2, 64, 64, 64, 64, 64, 1, 2, 65, - 65, 65, 65, 65, 1, 2, 66, 66, 66, 66, 66, 1, - 2, 67, 67, 67, 67, 67, 1, 2, 68, 68, 68, 68, - 68, 1, 2, 69, 69, 69, 69, 69, 1, 2, 70, 70, - 70, 70, 70, 1, 2, 71, 71, 71, 71, 71, 1, 2, - 72, 72, 72, 72, 72, 1, 2, 73, 73, 73, 73, 73, - 1, 2, 74, 74, 74, 74, 74, 1, 2, 75, 75, 75, - 75, 75, 1, 2, 76, 76, 76, 76, 76, 1, 2, 77, - 77, 77, 77, 77, 1, 2, 78, 78, 78, 78, 78, 1, - 2, 1, 1, 0 - }; -} - -private static final byte _http_parser_indicies[] = init__http_parser_indicies_0(); - - -private static byte[] init__http_parser_trans_targs_wi_0() -{ - return new byte [] { - 2, 0, 3, 38, 4, 24, 28, 25, 5, 20, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 57, 17, - 18, 19, 14, 18, 19, 14, 5, 21, 22, 5, 21, 22, - 23, 24, 25, 26, 27, 5, 28, 20, 29, 31, 34, 30, - 31, 32, 34, 33, 5, 35, 20, 36, 5, 35, 20, 36, - 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56 - }; -} - -private static final byte _http_parser_trans_targs_wi[] = init__http_parser_trans_targs_wi_0(); - - -private static byte[] init__http_parser_trans_actions_wi_0() -{ - return new byte [] { - 1, 0, 11, 0, 1, 1, 1, 1, 13, 13, 1, 0, - 0, 0, 0, 0, 0, 0, 19, 0, 0, 28, 23, 3, - 5, 7, 31, 7, 0, 9, 25, 1, 1, 15, 0, 0, - 0, 0, 0, 0, 0, 37, 0, 37, 0, 21, 21, 0, - 0, 0, 0, 0, 40, 17, 40, 17, 34, 0, 34, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 - }; -} - -private static final byte _http_parser_trans_actions_wi[] = init__http_parser_trans_actions_wi_0(); - - -static final int http_parser_start = 1; -static final int http_parser_first_final = 57; -static final int http_parser_error = 0; - -static final int http_parser_en_main = 1; - -// line 91 "http11_parser.rl" - -int http_parser_init(http_parser *parser) { - int cs = 0; - -// line 227 "../../ext/http11_java/org/jruby/mongrel/Http11Parser.java" - { - cs = http_parser_start; - } -// line 95 "http11_parser.rl" - parser->cs = cs; - parser->body_start = 0; - parser->content_len = 0; - parser->mark = 0; - parser->nread = 0; - parser->field_len = 0; - parser->field_start = 0; - - return(1); -} - - -/** exec **/ -size_t http_parser_execute(http_parser *parser, const char *buffer, size_t len, size_t off) { - const char *p, *pe; - int cs = parser->cs; - - assert(off <= len && "offset past end of buffer"); - - p = buffer+off; - pe = buffer+len; - - /* assert(*pe == '\0' && "pointer does not end on NUL"); */ - assert(pe - p == len - off && "pointers aren't same distance"); - - - -// line 259 "../../ext/http11_java/org/jruby/mongrel/Http11Parser.java" - { - int _klen; - int _trans = 0; - int _acts; - int _nacts; - int _keys; - int _goto_targ = 0; - - _goto: while (true) { - switch ( _goto_targ ) { - case 0: - if ( p == pe ) { - _goto_targ = 4; - continue _goto; - } - if ( cs == 0 ) { - _goto_targ = 5; - continue _goto; - } -case 1: - _match: do { - _keys = _http_parser_key_offsets[cs]; - _trans = _http_parser_index_offsets[cs]; - _klen = _http_parser_single_lengths[cs]; - if ( _klen > 0 ) { - int _lower = _keys; - int _mid; - int _upper = _keys + _klen - 1; - while (true) { - if ( _upper < _lower ) - break; - - _mid = _lower + ((_upper-_lower) >> 1); - if ( data[p] < _http_parser_trans_keys[_mid] ) - _upper = _mid - 1; - else if ( data[p] > _http_parser_trans_keys[_mid] ) - _lower = _mid + 1; - else { - _trans += (_mid - _keys); - break _match; - } - } - _keys += _klen; - _trans += _klen; - } - - _klen = _http_parser_range_lengths[cs]; - if ( _klen > 0 ) { - int _lower = _keys; - int _mid; - int _upper = _keys + (_klen<<1) - 2; - while (true) { - if ( _upper < _lower ) - break; - - _mid = _lower + (((_upper-_lower) >> 1) & ~1); - if ( data[p] < _http_parser_trans_keys[_mid] ) - _upper = _mid - 2; - else if ( data[p] > _http_parser_trans_keys[_mid+1] ) - _lower = _mid + 2; - else { - _trans += ((_mid - _keys)>>1); - break _match; - } - } - _trans += _klen; - } - } while (false); - - _trans = _http_parser_indicies[_trans]; - cs = _http_parser_trans_targs_wi[_trans]; - - if ( _http_parser_trans_actions_wi[_trans] != 0 ) { - _acts = _http_parser_trans_actions_wi[_trans]; - _nacts = (int) _http_parser_actions[_acts++]; - while ( _nacts-- > 0 ) - { - switch ( _http_parser_actions[_acts++] ) - { - case 0: -// line 34 "http11_parser.rl" - {MARK(mark, p); } - break; - case 1: -// line 37 "http11_parser.rl" - { MARK(field_start, p); } - break; - case 2: -// line 38 "http11_parser.rl" - { snake_upcase_char((char *)p); } - break; - case 3: -// line 39 "http11_parser.rl" - { - parser->field_len = LEN(field_start, p); - } - break; - case 4: -// line 43 "http11_parser.rl" - { MARK(mark, p); } - break; - case 5: -// line 44 "http11_parser.rl" - { - if(parser->http_field != NULL) { - parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p)); - } - } - break; - case 6: -// line 49 "http11_parser.rl" - { - if(parser->request_method != NULL) - parser->request_method(parser->data, PTR_TO(mark), LEN(mark, p)); - } - break; - case 7: -// line 53 "http11_parser.rl" - { - if(parser->request_uri != NULL) - parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p)); - } - break; - case 8: -// line 57 "http11_parser.rl" - { - if(parser->fragment != NULL) - parser->fragment(parser->data, PTR_TO(mark), LEN(mark, p)); - } - break; - case 9: -// line 62 "http11_parser.rl" - {MARK(query_start, p); } - break; - case 10: -// line 63 "http11_parser.rl" - { - if(parser->query_string != NULL) - parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p)); - } - break; - case 11: -// line 68 "http11_parser.rl" - { - if(parser->http_version != NULL) - parser->http_version(parser->data, PTR_TO(mark), LEN(mark, p)); - } - break; - case 12: -// line 73 "http11_parser.rl" - { - if(parser->request_path != NULL) - parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p)); - } - break; - case 13: -// line 78 "http11_parser.rl" - { - parser->body_start = p - buffer + 1; - if(parser->header_done != NULL) - parser->header_done(parser->data, p + 1, pe - p - 1); - { p += 1; _goto_targ = 5; if (true) continue _goto;} - } - break; -// line 424 "../../ext/http11_java/org/jruby/mongrel/Http11Parser.java" - } - } - } - -case 2: - if ( cs == 0 ) { - _goto_targ = 5; - continue _goto; - } - if ( ++p != pe ) { - _goto_targ = 1; - continue _goto; - } -case 4: -case 5: - } - break; } - } -// line 122 "http11_parser.rl" - - parser->cs = cs; - parser->nread += p - (buffer + off); - - assert(p <= pe && "buffer overflow after parsing execute"); - assert(parser->nread <= len && "nread longer than length"); - assert(parser->body_start <= len && "body starts after buffer end"); - assert(parser->mark < len && "mark is after buffer end"); - assert(parser->field_len <= len && "field has length longer than whole buffer"); - assert(parser->field_start < len && "field starts after buffer end"); - - return(parser->nread); -} - -int http_parser_finish(http_parser *parser) -{ - if (http_parser_has_error(parser) ) { - return -1; - } else if (http_parser_is_finished(parser) ) { - return 1; - } else { - return 0; - } -} - -int http_parser_has_error(http_parser *parser) { - return parser->cs == http_parser_error; -} - -int http_parser_is_finished(http_parser *parser) { - return parser->cs >= http_parser_first_final; -} -- cgit v1.2.3-24-ge0c7