unicorn 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,11 +19,7 @@ include Unicorn
19
19
 
20
20
  class RequestTest < Test::Unit::TestCase
21
21
 
22
- class MockRequest < StringIO
23
- def unicorn_peeraddr
24
- '666.666.666.666'
25
- end
26
- end
22
+ class MockRequest < StringIO; end
27
23
 
28
24
  def setup
29
25
  @request = HttpRequest.new(Logger.new($stderr))
@@ -38,23 +34,56 @@ class RequestTest < Test::Unit::TestCase
38
34
  "Host: foo\r\n\r\n")
39
35
  res = env = nil
40
36
  assert_nothing_raised { env = @request.read(client) }
41
- assert_equal '*', env['REQUEST_PATH']
42
- assert_equal '*', env['PATH_INFO']
37
+ assert_equal '', env['REQUEST_PATH']
38
+ assert_equal '', env['PATH_INFO']
43
39
  assert_equal '*', env['REQUEST_URI']
44
-
45
- # assert_nothing_raised { res = @lint.call(env) } # fails Rack lint
40
+ assert_nothing_raised { res = @lint.call(env) }
46
41
  end
47
42
 
48
- def test_full_url_path
43
+ def test_absolute_uri_with_query
49
44
  client = MockRequest.new("GET http://e:3/x?y=z HTTP/1.1\r\n" \
50
45
  "Host: foo\r\n\r\n")
51
46
  res = env = nil
52
47
  assert_nothing_raised { env = @request.read(client) }
53
48
  assert_equal '/x', env['REQUEST_PATH']
54
49
  assert_equal '/x', env['PATH_INFO']
50
+ assert_equal 'y=z', env['QUERY_STRING']
51
+ assert_nothing_raised { res = @lint.call(env) }
52
+ end
53
+
54
+ def test_absolute_uri_with_fragment
55
+ client = MockRequest.new("GET http://e:3/x#frag HTTP/1.1\r\n" \
56
+ "Host: foo\r\n\r\n")
57
+ res = env = nil
58
+ assert_nothing_raised { env = @request.read(client) }
59
+ assert_equal '/x', env['REQUEST_PATH']
60
+ assert_equal '/x', env['PATH_INFO']
61
+ assert_equal '', env['QUERY_STRING']
62
+ assert_equal 'frag', env['FRAGMENT']
55
63
  assert_nothing_raised { res = @lint.call(env) }
56
64
  end
57
65
 
66
+ def test_absolute_uri_with_query_and_fragment
67
+ client = MockRequest.new("GET http://e:3/x?a=b#frag HTTP/1.1\r\n" \
68
+ "Host: foo\r\n\r\n")
69
+ res = env = nil
70
+ assert_nothing_raised { env = @request.read(client) }
71
+ assert_equal '/x', env['REQUEST_PATH']
72
+ assert_equal '/x', env['PATH_INFO']
73
+ assert_equal 'a=b', env['QUERY_STRING']
74
+ assert_equal 'frag', env['FRAGMENT']
75
+ assert_nothing_raised { res = @lint.call(env) }
76
+ end
77
+
78
+ def test_absolute_uri_unsupported_schemes
79
+ %w(ssh+http://e/ ftp://e/x http+ssh://e/x).each do |abs_uri|
80
+ client = MockRequest.new("GET #{abs_uri} HTTP/1.1\r\n" \
81
+ "Host: foo\r\n\r\n")
82
+ assert_raises(HttpParserError) { @request.read(client) }
83
+ @request.reset
84
+ end
85
+ end
86
+
58
87
  def test_x_forwarded_proto_https
59
88
  res = env = nil
60
89
  client = MockRequest.new("GET / HTTP/1.1\r\n" \
@@ -90,7 +119,7 @@ class RequestTest < Test::Unit::TestCase
90
119
  res = env = nil
91
120
  assert_nothing_raised { env = @request.read(client) }
92
121
  assert_equal "http", env['rack.url_scheme']
93
- assert_equal '666.666.666.666', env['REMOTE_ADDR']
122
+ assert_equal '127.0.0.1', env['REMOTE_ADDR']
94
123
  assert_nothing_raised { res = @lint.call(env) }
95
124
  end
96
125
 
@@ -113,9 +142,6 @@ class RequestTest < Test::Unit::TestCase
113
142
  buf = (' ' * bs).freeze
114
143
  length = bs * count
115
144
  client = Tempfile.new('big_put')
116
- def client.unicorn_peeraddr
117
- '1.1.1.1'
118
- end
119
145
  client.syswrite(
120
146
  "PUT / HTTP/1.1\r\n" \
121
147
  "Host: foo\r\n" \
@@ -43,7 +43,7 @@ class ResponseTest < Test::Unit::TestCase
43
43
  HttpResponse.write(io, [code, {}, []])
44
44
  assert io.closed?
45
45
  lines = io.string.split(/\r\n/)
46
- assert_match(/.* #{HTTP_STATUS_CODES[code]}$/, lines.first,
46
+ assert_match(/.* Bad Request$/, lines.first,
47
47
  "wrong default reason phrase")
48
48
  end
49
49
 
@@ -10,6 +10,11 @@ class TestSocketHelper < Test::Unit::TestCase
10
10
  @log_tmp = Tempfile.new 'logger'
11
11
  @logger = Logger.new(@log_tmp.path)
12
12
  @test_addr = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1'
13
+ GC.disable
14
+ end
15
+
16
+ def teardown
17
+ GC.enable
13
18
  end
14
19
 
15
20
  def test_bind_listen_tcp
@@ -123,49 +128,4 @@ class TestSocketHelper < Test::Unit::TestCase
123
128
  sock_name(@unix_server)
124
129
  end
125
130
 
126
- def test_tcp_unicorn_peeraddr
127
- test_bind_listen_tcp
128
- @tcp_server = server_cast(@tcp_listener)
129
- tmp = Tempfile.new 'shared'
130
- pid = fork do
131
- client = @tcp_server.accept
132
- IO.select([client])
133
- assert_equal GET_SLASH, client.sysread(GET_SLASH.size)
134
- tmp.syswrite "#{client.unicorn_peeraddr}"
135
- exit 0
136
- end
137
- host, port = sock_name(@tcp_server).split(/:/)
138
- client = TCPSocket.new(host, port.to_i)
139
- client.syswrite(GET_SLASH)
140
-
141
- pid, status = Process.waitpid2(pid)
142
- assert_nothing_raised { client.close }
143
- assert status.success?
144
- tmp.sysseek 0
145
- assert_equal @test_addr, tmp.sysread(4096)
146
- tmp.sysseek 0
147
- end
148
-
149
- def test_unix_unicorn_peeraddr
150
- test_bind_listen_unix
151
- @unix_server = server_cast(@unix_listener)
152
- tmp = Tempfile.new 'shared'
153
- pid = fork do
154
- client = @unix_server.accept
155
- IO.select([client])
156
- assert_equal GET_SLASH, client.sysread(4096)
157
- tmp.syswrite "#{client.unicorn_peeraddr}"
158
- exit 0
159
- end
160
- client = UNIXSocket.new(@unix_listener_path)
161
- client.syswrite(GET_SLASH)
162
-
163
- pid, status = Process.waitpid2(pid)
164
- assert_nothing_raised { client.close }
165
- assert status.success?
166
- tmp.sysseek 0
167
- assert_equal '127.0.0.1', tmp.sysread(4096)
168
- tmp.sysseek 0
169
- end
170
-
171
131
  end
@@ -18,7 +18,8 @@ class UploadTest < Test::Unit::TestCase
18
18
  @sha1 = Digest::SHA1.new
19
19
  @sha1_app = lambda do |env|
20
20
  input = env['rack.input']
21
- resp = { :pos => input.pos, :size => input.stat.size }
21
+ resp = { :pos => input.pos, :size => input.size, :class => input.class }
22
+ @sha1.reset
22
23
  begin
23
24
  loop { @sha1.update(input.sysread(@bs)) }
24
25
  rescue EOFError
@@ -216,6 +217,22 @@ class UploadTest < Test::Unit::TestCase
216
217
  resp = `curl -isSfN -T#{tmp.path} http://#@addr:#@port/`
217
218
  assert $?.success?, 'curl ran OK'
218
219
  assert_match(%r!\b#{sha1}\b!, resp)
220
+ assert_match(/Tempfile/, resp)
221
+
222
+ # small StringIO path
223
+ assert(system("dd", "if=#{@random.path}", "of=#{tmp.path}",
224
+ "bs=1024", "count=1"),
225
+ "dd #@random to #{tmp}")
226
+ sha1_re = %r!\b([a-f0-9]{40})\b!
227
+ sha1_out = `sha1sum #{tmp.path}`
228
+ assert $?.success?, 'sha1sum ran OK'
229
+
230
+ assert_match(sha1_re, sha1_out)
231
+ sha1 = sha1_re.match(sha1_out)[1]
232
+ resp = `curl -isSfN -T#{tmp.path} http://#@addr:#@port/`
233
+ assert $?.success?, 'curl ran OK'
234
+ assert_match(%r!\b#{sha1}\b!, resp)
235
+ assert_match(/StringIO/, resp)
219
236
  end
220
237
 
221
238
  private
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{unicorn}
5
- s.version = "0.5.4"
5
+ s.version = "0.6.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Eric Wong"]
9
- s.date = %q{2009-04-23}
9
+ s.date = %q{2009-04-24}
10
10
  s.description = %q{A small fast HTTP library and server for Rack applications.}
11
11
  s.email = %q{normalperson@yhbt.net}
12
12
  s.executables = ["unicorn", "unicorn_rails"]
13
13
  s.extensions = ["ext/unicorn/http11/extconf.rb"]
14
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "TODO", "bin/unicorn", "bin/unicorn_rails", "ext/unicorn/http11/ext_help.h", "ext/unicorn/http11/extconf.rb", "ext/unicorn/http11/http11.c", "ext/unicorn/http11/http11_parser.c", "ext/unicorn/http11/http11_parser.h", "ext/unicorn/http11/http11_parser.rl", "ext/unicorn/http11/http11_parser_common.rl", "lib/unicorn.rb", "lib/unicorn/app/exec_cgi.rb", "lib/unicorn/app/old_rails.rb", "lib/unicorn/app/old_rails/static.rb", "lib/unicorn/cgi_wrapper.rb", "lib/unicorn/configurator.rb", "lib/unicorn/const.rb", "lib/unicorn/http_request.rb", "lib/unicorn/http_response.rb", "lib/unicorn/launcher.rb", "lib/unicorn/socket.rb", "lib/unicorn/util.rb"]
15
- s.files = [".document", ".gitignore", "CHANGELOG", "CONTRIBUTORS", "DESIGN", "GNUmakefile", "LICENSE", "Manifest", "PHILOSOPHY", "README", "Rakefile", "SIGNALS", "TODO", "bin/unicorn", "bin/unicorn_rails", "ext/unicorn/http11/ext_help.h", "ext/unicorn/http11/extconf.rb", "ext/unicorn/http11/http11.c", "ext/unicorn/http11/http11_parser.c", "ext/unicorn/http11/http11_parser.h", "ext/unicorn/http11/http11_parser.rl", "ext/unicorn/http11/http11_parser_common.rl", "lib/unicorn.rb", "lib/unicorn/app/exec_cgi.rb", "lib/unicorn/app/old_rails.rb", "lib/unicorn/app/old_rails/static.rb", "lib/unicorn/cgi_wrapper.rb", "lib/unicorn/configurator.rb", "lib/unicorn/const.rb", "lib/unicorn/http_request.rb", "lib/unicorn/http_response.rb", "lib/unicorn/launcher.rb", "lib/unicorn/socket.rb", "lib/unicorn/util.rb", "local.mk.sample", "setup.rb", "test/aggregate.rb", "test/benchmark/README", "test/benchmark/big_request.rb", "test/benchmark/dd.ru", "test/benchmark/request.rb", "test/benchmark/response.rb", "test/exec/README", "test/exec/test_exec.rb", "test/rails/app-1.2.3/.gitignore", "test/rails/app-1.2.3/Rakefile", "test/rails/app-1.2.3/app/controllers/application.rb", "test/rails/app-1.2.3/app/controllers/foo_controller.rb", "test/rails/app-1.2.3/app/helpers/application_helper.rb", "test/rails/app-1.2.3/config/boot.rb", "test/rails/app-1.2.3/config/database.yml", "test/rails/app-1.2.3/config/environment.rb", "test/rails/app-1.2.3/config/environments/development.rb", "test/rails/app-1.2.3/config/environments/production.rb", "test/rails/app-1.2.3/config/routes.rb", "test/rails/app-1.2.3/db/.gitignore", "test/rails/app-1.2.3/log/.gitignore", "test/rails/app-1.2.3/public/404.html", "test/rails/app-1.2.3/public/500.html", "test/rails/app-2.0.2/.gitignore", "test/rails/app-2.0.2/Rakefile", "test/rails/app-2.0.2/app/controllers/application.rb", "test/rails/app-2.0.2/app/controllers/foo_controller.rb", "test/rails/app-2.0.2/app/helpers/application_helper.rb", "test/rails/app-2.0.2/config/boot.rb", "test/rails/app-2.0.2/config/database.yml", "test/rails/app-2.0.2/config/environment.rb", "test/rails/app-2.0.2/config/environments/development.rb", "test/rails/app-2.0.2/config/environments/production.rb", "test/rails/app-2.0.2/config/routes.rb", "test/rails/app-2.0.2/db/.gitignore", "test/rails/app-2.0.2/log/.gitignore", "test/rails/app-2.0.2/public/404.html", "test/rails/app-2.0.2/public/500.html", "test/rails/app-2.1.2/.gitignore", "test/rails/app-2.1.2/Rakefile", "test/rails/app-2.1.2/app/controllers/application.rb", "test/rails/app-2.1.2/app/controllers/foo_controller.rb", "test/rails/app-2.1.2/app/helpers/application_helper.rb", "test/rails/app-2.1.2/config/boot.rb", "test/rails/app-2.1.2/config/database.yml", "test/rails/app-2.1.2/config/environment.rb", "test/rails/app-2.1.2/config/environments/development.rb", "test/rails/app-2.1.2/config/environments/production.rb", "test/rails/app-2.1.2/config/routes.rb", "test/rails/app-2.1.2/db/.gitignore", "test/rails/app-2.1.2/log/.gitignore", "test/rails/app-2.1.2/public/404.html", "test/rails/app-2.1.2/public/500.html", "test/rails/app-2.2.2/.gitignore", "test/rails/app-2.2.2/Rakefile", "test/rails/app-2.2.2/app/controllers/application.rb", "test/rails/app-2.2.2/app/controllers/foo_controller.rb", "test/rails/app-2.2.2/app/helpers/application_helper.rb", "test/rails/app-2.2.2/config/boot.rb", "test/rails/app-2.2.2/config/database.yml", "test/rails/app-2.2.2/config/environment.rb", "test/rails/app-2.2.2/config/environments/development.rb", "test/rails/app-2.2.2/config/environments/production.rb", "test/rails/app-2.2.2/config/routes.rb", "test/rails/app-2.2.2/db/.gitignore", "test/rails/app-2.2.2/log/.gitignore", "test/rails/app-2.2.2/public/404.html", "test/rails/app-2.2.2/public/500.html", "test/rails/app-2.3.2.1/.gitignore", "test/rails/app-2.3.2.1/Rakefile", "test/rails/app-2.3.2.1/app/controllers/application_controller.rb", "test/rails/app-2.3.2.1/app/controllers/foo_controller.rb", "test/rails/app-2.3.2.1/app/helpers/application_helper.rb", "test/rails/app-2.3.2.1/config/boot.rb", "test/rails/app-2.3.2.1/config/database.yml", "test/rails/app-2.3.2.1/config/environment.rb", "test/rails/app-2.3.2.1/config/environments/development.rb", "test/rails/app-2.3.2.1/config/environments/production.rb", "test/rails/app-2.3.2.1/config/routes.rb", "test/rails/app-2.3.2.1/db/.gitignore", "test/rails/app-2.3.2.1/log/.gitignore", "test/rails/app-2.3.2.1/public/404.html", "test/rails/app-2.3.2.1/public/500.html", "test/rails/test_rails.rb", "test/test_helper.rb", "test/tools/trickletest.rb", "test/unit/test_configurator.rb", "test/unit/test_http_parser.rb", "test/unit/test_request.rb", "test/unit/test_response.rb", "test/unit/test_server.rb", "test/unit/test_signals.rb", "test/unit/test_socket_helper.rb", "test/unit/test_upload.rb", "unicorn.gemspec"]
14
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "TODO", "bin/unicorn", "bin/unicorn_rails", "ext/unicorn/http11/ext_help.h", "ext/unicorn/http11/extconf.rb", "ext/unicorn/http11/http11.c", "ext/unicorn/http11/http11_parser.h", "ext/unicorn/http11/http11_parser.rl", "ext/unicorn/http11/http11_parser_common.rl", "lib/unicorn.rb", "lib/unicorn/app/exec_cgi.rb", "lib/unicorn/app/old_rails.rb", "lib/unicorn/app/old_rails/static.rb", "lib/unicorn/cgi_wrapper.rb", "lib/unicorn/configurator.rb", "lib/unicorn/const.rb", "lib/unicorn/http_request.rb", "lib/unicorn/http_response.rb", "lib/unicorn/launcher.rb", "lib/unicorn/socket_helper.rb", "lib/unicorn/util.rb"]
15
+ s.files = [".document", ".gitignore", "CHANGELOG", "CONTRIBUTORS", "DESIGN", "GNUmakefile", "LICENSE", "Manifest", "PHILOSOPHY", "README", "Rakefile", "SIGNALS", "TODO", "bin/unicorn", "bin/unicorn_rails", "ext/unicorn/http11/ext_help.h", "ext/unicorn/http11/extconf.rb", "ext/unicorn/http11/http11.c", "ext/unicorn/http11/http11_parser.h", "ext/unicorn/http11/http11_parser.rl", "ext/unicorn/http11/http11_parser_common.rl", "lib/unicorn.rb", "lib/unicorn/app/exec_cgi.rb", "lib/unicorn/app/old_rails.rb", "lib/unicorn/app/old_rails/static.rb", "lib/unicorn/cgi_wrapper.rb", "lib/unicorn/configurator.rb", "lib/unicorn/const.rb", "lib/unicorn/http_request.rb", "lib/unicorn/http_response.rb", "lib/unicorn/launcher.rb", "lib/unicorn/socket_helper.rb", "lib/unicorn/util.rb", "local.mk.sample", "setup.rb", "test/aggregate.rb", "test/benchmark/README", "test/benchmark/big_request.rb", "test/benchmark/dd.ru", "test/benchmark/request.rb", "test/benchmark/response.rb", "test/exec/README", "test/exec/test_exec.rb", "test/rails/app-1.2.3/.gitignore", "test/rails/app-1.2.3/Rakefile", "test/rails/app-1.2.3/app/controllers/application.rb", "test/rails/app-1.2.3/app/controllers/foo_controller.rb", "test/rails/app-1.2.3/app/helpers/application_helper.rb", "test/rails/app-1.2.3/config/boot.rb", "test/rails/app-1.2.3/config/database.yml", "test/rails/app-1.2.3/config/environment.rb", "test/rails/app-1.2.3/config/environments/development.rb", "test/rails/app-1.2.3/config/environments/production.rb", "test/rails/app-1.2.3/config/routes.rb", "test/rails/app-1.2.3/db/.gitignore", "test/rails/app-1.2.3/log/.gitignore", "test/rails/app-1.2.3/public/404.html", "test/rails/app-1.2.3/public/500.html", "test/rails/app-2.0.2/.gitignore", "test/rails/app-2.0.2/Rakefile", "test/rails/app-2.0.2/app/controllers/application.rb", "test/rails/app-2.0.2/app/controllers/foo_controller.rb", "test/rails/app-2.0.2/app/helpers/application_helper.rb", "test/rails/app-2.0.2/config/boot.rb", "test/rails/app-2.0.2/config/database.yml", "test/rails/app-2.0.2/config/environment.rb", "test/rails/app-2.0.2/config/environments/development.rb", "test/rails/app-2.0.2/config/environments/production.rb", "test/rails/app-2.0.2/config/routes.rb", "test/rails/app-2.0.2/db/.gitignore", "test/rails/app-2.0.2/log/.gitignore", "test/rails/app-2.0.2/public/404.html", "test/rails/app-2.0.2/public/500.html", "test/rails/app-2.1.2/.gitignore", "test/rails/app-2.1.2/Rakefile", "test/rails/app-2.1.2/app/controllers/application.rb", "test/rails/app-2.1.2/app/controllers/foo_controller.rb", "test/rails/app-2.1.2/app/helpers/application_helper.rb", "test/rails/app-2.1.2/config/boot.rb", "test/rails/app-2.1.2/config/database.yml", "test/rails/app-2.1.2/config/environment.rb", "test/rails/app-2.1.2/config/environments/development.rb", "test/rails/app-2.1.2/config/environments/production.rb", "test/rails/app-2.1.2/config/routes.rb", "test/rails/app-2.1.2/db/.gitignore", "test/rails/app-2.1.2/log/.gitignore", "test/rails/app-2.1.2/public/404.html", "test/rails/app-2.1.2/public/500.html", "test/rails/app-2.2.2/.gitignore", "test/rails/app-2.2.2/Rakefile", "test/rails/app-2.2.2/app/controllers/application.rb", "test/rails/app-2.2.2/app/controllers/foo_controller.rb", "test/rails/app-2.2.2/app/helpers/application_helper.rb", "test/rails/app-2.2.2/config/boot.rb", "test/rails/app-2.2.2/config/database.yml", "test/rails/app-2.2.2/config/environment.rb", "test/rails/app-2.2.2/config/environments/development.rb", "test/rails/app-2.2.2/config/environments/production.rb", "test/rails/app-2.2.2/config/routes.rb", "test/rails/app-2.2.2/db/.gitignore", "test/rails/app-2.2.2/log/.gitignore", "test/rails/app-2.2.2/public/404.html", "test/rails/app-2.2.2/public/500.html", "test/rails/app-2.3.2.1/.gitignore", "test/rails/app-2.3.2.1/Rakefile", "test/rails/app-2.3.2.1/app/controllers/application_controller.rb", "test/rails/app-2.3.2.1/app/controllers/foo_controller.rb", "test/rails/app-2.3.2.1/app/helpers/application_helper.rb", "test/rails/app-2.3.2.1/config/boot.rb", "test/rails/app-2.3.2.1/config/database.yml", "test/rails/app-2.3.2.1/config/environment.rb", "test/rails/app-2.3.2.1/config/environments/development.rb", "test/rails/app-2.3.2.1/config/environments/production.rb", "test/rails/app-2.3.2.1/config/routes.rb", "test/rails/app-2.3.2.1/db/.gitignore", "test/rails/app-2.3.2.1/log/.gitignore", "test/rails/app-2.3.2.1/public/404.html", "test/rails/app-2.3.2.1/public/500.html", "test/rails/test_rails.rb", "test/test_helper.rb", "test/tools/trickletest.rb", "test/unit/test_configurator.rb", "test/unit/test_http_parser.rb", "test/unit/test_request.rb", "test/unit/test_response.rb", "test/unit/test_server.rb", "test/unit/test_signals.rb", "test/unit/test_socket_helper.rb", "test/unit/test_upload.rb", "unicorn.gemspec"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://unicorn.bogomips.org}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Unicorn", "--main", "README"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Wong
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-23 00:00:00 -07:00
12
+ date: 2009-04-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,7 +30,6 @@ extra_rdoc_files:
30
30
  - ext/unicorn/http11/ext_help.h
31
31
  - ext/unicorn/http11/extconf.rb
32
32
  - ext/unicorn/http11/http11.c
33
- - ext/unicorn/http11/http11_parser.c
34
33
  - ext/unicorn/http11/http11_parser.h
35
34
  - ext/unicorn/http11/http11_parser.rl
36
35
  - ext/unicorn/http11/http11_parser_common.rl
@@ -44,7 +43,7 @@ extra_rdoc_files:
44
43
  - lib/unicorn/http_request.rb
45
44
  - lib/unicorn/http_response.rb
46
45
  - lib/unicorn/launcher.rb
47
- - lib/unicorn/socket.rb
46
+ - lib/unicorn/socket_helper.rb
48
47
  - lib/unicorn/util.rb
49
48
  files:
50
49
  - .document
@@ -65,7 +64,6 @@ files:
65
64
  - ext/unicorn/http11/ext_help.h
66
65
  - ext/unicorn/http11/extconf.rb
67
66
  - ext/unicorn/http11/http11.c
68
- - ext/unicorn/http11/http11_parser.c
69
67
  - ext/unicorn/http11/http11_parser.h
70
68
  - ext/unicorn/http11/http11_parser.rl
71
69
  - ext/unicorn/http11/http11_parser_common.rl
@@ -79,7 +77,7 @@ files:
79
77
  - lib/unicorn/http_request.rb
80
78
  - lib/unicorn/http_response.rb
81
79
  - lib/unicorn/launcher.rb
82
- - lib/unicorn/socket.rb
80
+ - lib/unicorn/socket_helper.rb
83
81
  - lib/unicorn/util.rb
84
82
  - local.mk.sample
85
83
  - setup.rb
@@ -1,1221 +0,0 @@
1
- #line 1 "http11_parser.rl"
2
- /**
3
- * Copyright (c) 2005 Zed A. Shaw
4
- * You can redistribute it and/or modify it under the same terms as Ruby.
5
- */
6
- #include "http11_parser.h"
7
- #include <stdio.h>
8
- #include <assert.h>
9
- #include <stdlib.h>
10
- #include <ctype.h>
11
- #include <string.h>
12
-
13
- /*
14
- * capitalizes all lower-case ASCII characters,
15
- * converts dashes to underscores.
16
- */
17
- static void snake_upcase_char(char *c)
18
- {
19
- if (*c >= 'a' && *c <= 'z')
20
- *c &= ~0x20;
21
- else if (*c == '-')
22
- *c = '_';
23
- }
24
-
25
- #define LEN(AT, FPC) (FPC - buffer - parser->AT)
26
- #define MARK(M,FPC) (parser->M = (FPC) - buffer)
27
- #define PTR_TO(F) (buffer + parser->F)
28
-
29
- /** Machine **/
30
-
31
- #line 87 "http11_parser.rl"
32
-
33
-
34
- /** Data **/
35
-
36
- #line 37 "http11_parser.c"
37
- static const int http_parser_start = 1;
38
- static const int http_parser_first_final = 57;
39
- static const int http_parser_error = 0;
40
-
41
- static const int http_parser_en_main = 1;
42
-
43
- #line 91 "http11_parser.rl"
44
-
45
- int http_parser_init(http_parser *parser) {
46
- int cs = 0;
47
-
48
- #line 49 "http11_parser.c"
49
- {
50
- cs = http_parser_start;
51
- }
52
- #line 95 "http11_parser.rl"
53
- parser->cs = cs;
54
- parser->body_start = 0;
55
- parser->content_len = 0;
56
- parser->mark = 0;
57
- parser->nread = 0;
58
- parser->field_len = 0;
59
- parser->field_start = 0;
60
-
61
- return(1);
62
- }
63
-
64
-
65
- /** exec **/
66
- size_t http_parser_execute(http_parser *parser, const char *buffer, size_t len) {
67
- const char *p, *pe;
68
- int cs = parser->cs;
69
- size_t off = parser->nread;
70
-
71
- assert(off <= len && "offset past end of buffer");
72
-
73
- p = buffer+off;
74
- pe = buffer+len;
75
-
76
- assert(*pe == '\0' && "pointer does not end on NUL");
77
- assert(pe - p == len - off && "pointers aren't same distance");
78
-
79
-
80
- #line 81 "http11_parser.c"
81
- {
82
- if ( p == pe )
83
- goto _test_eof;
84
- switch ( cs )
85
- {
86
- case 1:
87
- switch( (*p) ) {
88
- case 36: goto tr0;
89
- case 95: goto tr0;
90
- }
91
- if ( (*p) < 48 ) {
92
- if ( 45 <= (*p) && (*p) <= 46 )
93
- goto tr0;
94
- } else if ( (*p) > 57 ) {
95
- if ( 65 <= (*p) && (*p) <= 90 )
96
- goto tr0;
97
- } else
98
- goto tr0;
99
- goto st0;
100
- st0:
101
- cs = 0;
102
- goto _out;
103
- tr0:
104
- #line 34 "http11_parser.rl"
105
- {MARK(mark, p); }
106
- goto st2;
107
- st2:
108
- if ( ++p == pe )
109
- goto _test_eof2;
110
- case 2:
111
- #line 112 "http11_parser.c"
112
- switch( (*p) ) {
113
- case 32: goto tr2;
114
- case 36: goto st38;
115
- case 95: goto st38;
116
- }
117
- if ( (*p) < 48 ) {
118
- if ( 45 <= (*p) && (*p) <= 46 )
119
- goto st38;
120
- } else if ( (*p) > 57 ) {
121
- if ( 65 <= (*p) && (*p) <= 90 )
122
- goto st38;
123
- } else
124
- goto st38;
125
- goto st0;
126
- tr2:
127
- #line 49 "http11_parser.rl"
128
- {
129
- if(parser->request_method != NULL)
130
- parser->request_method(parser->data, PTR_TO(mark), LEN(mark, p));
131
- }
132
- goto st3;
133
- st3:
134
- if ( ++p == pe )
135
- goto _test_eof3;
136
- case 3:
137
- #line 138 "http11_parser.c"
138
- switch( (*p) ) {
139
- case 42: goto tr4;
140
- case 43: goto tr5;
141
- case 47: goto tr6;
142
- case 58: goto tr7;
143
- }
144
- if ( (*p) < 65 ) {
145
- if ( 45 <= (*p) && (*p) <= 57 )
146
- goto tr5;
147
- } else if ( (*p) > 90 ) {
148
- if ( 97 <= (*p) && (*p) <= 122 )
149
- goto tr5;
150
- } else
151
- goto tr5;
152
- goto st0;
153
- tr4:
154
- #line 34 "http11_parser.rl"
155
- {MARK(mark, p); }
156
- goto st4;
157
- st4:
158
- if ( ++p == pe )
159
- goto _test_eof4;
160
- case 4:
161
- #line 162 "http11_parser.c"
162
- switch( (*p) ) {
163
- case 32: goto tr8;
164
- case 35: goto tr9;
165
- }
166
- goto st0;
167
- tr8:
168
- #line 53 "http11_parser.rl"
169
- {
170
- if(parser->request_uri != NULL)
171
- parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
172
- }
173
- goto st5;
174
- tr31:
175
- #line 34 "http11_parser.rl"
176
- {MARK(mark, p); }
177
- #line 57 "http11_parser.rl"
178
- {
179
- if(parser->fragment != NULL)
180
- parser->fragment(parser->data, PTR_TO(mark), LEN(mark, p));
181
- }
182
- goto st5;
183
- tr34:
184
- #line 57 "http11_parser.rl"
185
- {
186
- if(parser->fragment != NULL)
187
- parser->fragment(parser->data, PTR_TO(mark), LEN(mark, p));
188
- }
189
- goto st5;
190
- tr42:
191
- #line 73 "http11_parser.rl"
192
- {
193
- if(parser->request_path != NULL)
194
- parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
195
- }
196
- #line 53 "http11_parser.rl"
197
- {
198
- if(parser->request_uri != NULL)
199
- parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
200
- }
201
- goto st5;
202
- tr53:
203
- #line 62 "http11_parser.rl"
204
- {MARK(query_start, p); }
205
- #line 63 "http11_parser.rl"
206
- {
207
- if(parser->query_string != NULL)
208
- parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
209
- }
210
- #line 53 "http11_parser.rl"
211
- {
212
- if(parser->request_uri != NULL)
213
- parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
214
- }
215
- goto st5;
216
- tr57:
217
- #line 63 "http11_parser.rl"
218
- {
219
- if(parser->query_string != NULL)
220
- parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
221
- }
222
- #line 53 "http11_parser.rl"
223
- {
224
- if(parser->request_uri != NULL)
225
- parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
226
- }
227
- goto st5;
228
- st5:
229
- if ( ++p == pe )
230
- goto _test_eof5;
231
- case 5:
232
- #line 233 "http11_parser.c"
233
- if ( (*p) == 72 )
234
- goto tr10;
235
- goto st0;
236
- tr10:
237
- #line 34 "http11_parser.rl"
238
- {MARK(mark, p); }
239
- goto st6;
240
- st6:
241
- if ( ++p == pe )
242
- goto _test_eof6;
243
- case 6:
244
- #line 245 "http11_parser.c"
245
- if ( (*p) == 84 )
246
- goto st7;
247
- goto st0;
248
- st7:
249
- if ( ++p == pe )
250
- goto _test_eof7;
251
- case 7:
252
- if ( (*p) == 84 )
253
- goto st8;
254
- goto st0;
255
- st8:
256
- if ( ++p == pe )
257
- goto _test_eof8;
258
- case 8:
259
- if ( (*p) == 80 )
260
- goto st9;
261
- goto st0;
262
- st9:
263
- if ( ++p == pe )
264
- goto _test_eof9;
265
- case 9:
266
- if ( (*p) == 47 )
267
- goto st10;
268
- goto st0;
269
- st10:
270
- if ( ++p == pe )
271
- goto _test_eof10;
272
- case 10:
273
- if ( 48 <= (*p) && (*p) <= 57 )
274
- goto st11;
275
- goto st0;
276
- st11:
277
- if ( ++p == pe )
278
- goto _test_eof11;
279
- case 11:
280
- if ( (*p) == 46 )
281
- goto st12;
282
- if ( 48 <= (*p) && (*p) <= 57 )
283
- goto st11;
284
- goto st0;
285
- st12:
286
- if ( ++p == pe )
287
- goto _test_eof12;
288
- case 12:
289
- if ( 48 <= (*p) && (*p) <= 57 )
290
- goto st13;
291
- goto st0;
292
- st13:
293
- if ( ++p == pe )
294
- goto _test_eof13;
295
- case 13:
296
- if ( (*p) == 13 )
297
- goto tr18;
298
- if ( 48 <= (*p) && (*p) <= 57 )
299
- goto st13;
300
- goto st0;
301
- tr18:
302
- #line 68 "http11_parser.rl"
303
- {
304
- if(parser->http_version != NULL)
305
- parser->http_version(parser->data, PTR_TO(mark), LEN(mark, p));
306
- }
307
- goto st14;
308
- tr26:
309
- #line 43 "http11_parser.rl"
310
- { MARK(mark, p); }
311
- #line 44 "http11_parser.rl"
312
- {
313
- if(parser->http_field != NULL) {
314
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
315
- }
316
- }
317
- goto st14;
318
- tr29:
319
- #line 44 "http11_parser.rl"
320
- {
321
- if(parser->http_field != NULL) {
322
- parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
323
- }
324
- }
325
- goto st14;
326
- st14:
327
- if ( ++p == pe )
328
- goto _test_eof14;
329
- case 14:
330
- #line 331 "http11_parser.c"
331
- if ( (*p) == 10 )
332
- goto st15;
333
- goto st0;
334
- st15:
335
- if ( ++p == pe )
336
- goto _test_eof15;
337
- case 15:
338
- switch( (*p) ) {
339
- case 13: goto st16;
340
- case 33: goto tr21;
341
- case 124: goto tr21;
342
- case 126: goto tr21;
343
- }
344
- if ( (*p) < 45 ) {
345
- if ( (*p) > 39 ) {
346
- if ( 42 <= (*p) && (*p) <= 43 )
347
- goto tr21;
348
- } else if ( (*p) >= 35 )
349
- goto tr21;
350
- } else if ( (*p) > 46 ) {
351
- if ( (*p) < 65 ) {
352
- if ( 48 <= (*p) && (*p) <= 57 )
353
- goto tr21;
354
- } else if ( (*p) > 90 ) {
355
- if ( 94 <= (*p) && (*p) <= 122 )
356
- goto tr21;
357
- } else
358
- goto tr21;
359
- } else
360
- goto tr21;
361
- goto st0;
362
- st16:
363
- if ( ++p == pe )
364
- goto _test_eof16;
365
- case 16:
366
- if ( (*p) == 10 )
367
- goto tr22;
368
- goto st0;
369
- tr22:
370
- #line 78 "http11_parser.rl"
371
- {
372
- parser->body_start = p - buffer + 1;
373
- if(parser->header_done != NULL)
374
- parser->header_done(parser->data, p + 1, pe - p - 1);
375
- {p++; cs = 57; goto _out;}
376
- }
377
- goto st57;
378
- st57:
379
- if ( ++p == pe )
380
- goto _test_eof57;
381
- case 57:
382
- #line 383 "http11_parser.c"
383
- goto st0;
384
- tr21:
385
- #line 37 "http11_parser.rl"
386
- { MARK(field_start, p); }
387
- #line 38 "http11_parser.rl"
388
- { snake_upcase_char((char *)p); }
389
- goto st17;
390
- tr23:
391
- #line 38 "http11_parser.rl"
392
- { snake_upcase_char((char *)p); }
393
- goto st17;
394
- st17:
395
- if ( ++p == pe )
396
- goto _test_eof17;
397
- case 17:
398
- #line 399 "http11_parser.c"
399
- switch( (*p) ) {
400
- case 33: goto tr23;
401
- case 58: goto tr24;
402
- case 124: goto tr23;
403
- case 126: goto tr23;
404
- }
405
- if ( (*p) < 45 ) {
406
- if ( (*p) > 39 ) {
407
- if ( 42 <= (*p) && (*p) <= 43 )
408
- goto tr23;
409
- } else if ( (*p) >= 35 )
410
- goto tr23;
411
- } else if ( (*p) > 46 ) {
412
- if ( (*p) < 65 ) {
413
- if ( 48 <= (*p) && (*p) <= 57 )
414
- goto tr23;
415
- } else if ( (*p) > 90 ) {
416
- if ( 94 <= (*p) && (*p) <= 122 )
417
- goto tr23;
418
- } else
419
- goto tr23;
420
- } else
421
- goto tr23;
422
- goto st0;
423
- tr24:
424
- #line 39 "http11_parser.rl"
425
- {
426
- parser->field_len = LEN(field_start, p);
427
- }
428
- goto st18;
429
- tr27:
430
- #line 43 "http11_parser.rl"
431
- { MARK(mark, p); }
432
- goto st18;
433
- st18:
434
- if ( ++p == pe )
435
- goto _test_eof18;
436
- case 18:
437
- #line 438 "http11_parser.c"
438
- switch( (*p) ) {
439
- case 13: goto tr26;
440
- case 32: goto tr27;
441
- }
442
- goto tr25;
443
- tr25:
444
- #line 43 "http11_parser.rl"
445
- { MARK(mark, p); }
446
- goto st19;
447
- st19:
448
- if ( ++p == pe )
449
- goto _test_eof19;
450
- case 19:
451
- #line 452 "http11_parser.c"
452
- if ( (*p) == 13 )
453
- goto tr29;
454
- goto st19;
455
- tr9:
456
- #line 53 "http11_parser.rl"
457
- {
458
- if(parser->request_uri != NULL)
459
- parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
460
- }
461
- goto st20;
462
- tr43:
463
- #line 73 "http11_parser.rl"
464
- {
465
- if(parser->request_path != NULL)
466
- parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
467
- }
468
- #line 53 "http11_parser.rl"
469
- {
470
- if(parser->request_uri != NULL)
471
- parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
472
- }
473
- goto st20;
474
- tr54:
475
- #line 62 "http11_parser.rl"
476
- {MARK(query_start, p); }
477
- #line 63 "http11_parser.rl"
478
- {
479
- if(parser->query_string != NULL)
480
- parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
481
- }
482
- #line 53 "http11_parser.rl"
483
- {
484
- if(parser->request_uri != NULL)
485
- parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
486
- }
487
- goto st20;
488
- tr58:
489
- #line 63 "http11_parser.rl"
490
- {
491
- if(parser->query_string != NULL)
492
- parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
493
- }
494
- #line 53 "http11_parser.rl"
495
- {
496
- if(parser->request_uri != NULL)
497
- parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
498
- }
499
- goto st20;
500
- st20:
501
- if ( ++p == pe )
502
- goto _test_eof20;
503
- case 20:
504
- #line 505 "http11_parser.c"
505
- switch( (*p) ) {
506
- case 32: goto tr31;
507
- case 35: goto st0;
508
- case 37: goto tr32;
509
- case 127: goto st0;
510
- }
511
- if ( 0 <= (*p) && (*p) <= 31 )
512
- goto st0;
513
- goto tr30;
514
- tr30:
515
- #line 34 "http11_parser.rl"
516
- {MARK(mark, p); }
517
- goto st21;
518
- st21:
519
- if ( ++p == pe )
520
- goto _test_eof21;
521
- case 21:
522
- #line 523 "http11_parser.c"
523
- switch( (*p) ) {
524
- case 32: goto tr34;
525
- case 35: goto st0;
526
- case 37: goto st22;
527
- case 127: goto st0;
528
- }
529
- if ( 0 <= (*p) && (*p) <= 31 )
530
- goto st0;
531
- goto st21;
532
- tr32:
533
- #line 34 "http11_parser.rl"
534
- {MARK(mark, p); }
535
- goto st22;
536
- st22:
537
- if ( ++p == pe )
538
- goto _test_eof22;
539
- case 22:
540
- #line 541 "http11_parser.c"
541
- if ( (*p) < 65 ) {
542
- if ( 48 <= (*p) && (*p) <= 57 )
543
- goto st23;
544
- } else if ( (*p) > 70 ) {
545
- if ( 97 <= (*p) && (*p) <= 102 )
546
- goto st23;
547
- } else
548
- goto st23;
549
- goto st0;
550
- st23:
551
- if ( ++p == pe )
552
- goto _test_eof23;
553
- case 23:
554
- if ( (*p) < 65 ) {
555
- if ( 48 <= (*p) && (*p) <= 57 )
556
- goto st21;
557
- } else if ( (*p) > 70 ) {
558
- if ( 97 <= (*p) && (*p) <= 102 )
559
- goto st21;
560
- } else
561
- goto st21;
562
- goto st0;
563
- tr5:
564
- #line 34 "http11_parser.rl"
565
- {MARK(mark, p); }
566
- goto st24;
567
- st24:
568
- if ( ++p == pe )
569
- goto _test_eof24;
570
- case 24:
571
- #line 572 "http11_parser.c"
572
- switch( (*p) ) {
573
- case 43: goto st24;
574
- case 58: goto st25;
575
- }
576
- if ( (*p) < 48 ) {
577
- if ( 45 <= (*p) && (*p) <= 46 )
578
- goto st24;
579
- } else if ( (*p) > 57 ) {
580
- if ( (*p) > 90 ) {
581
- if ( 97 <= (*p) && (*p) <= 122 )
582
- goto st24;
583
- } else if ( (*p) >= 65 )
584
- goto st24;
585
- } else
586
- goto st24;
587
- goto st0;
588
- tr7:
589
- #line 34 "http11_parser.rl"
590
- {MARK(mark, p); }
591
- goto st25;
592
- st25:
593
- if ( ++p == pe )
594
- goto _test_eof25;
595
- case 25:
596
- #line 597 "http11_parser.c"
597
- switch( (*p) ) {
598
- case 32: goto tr8;
599
- case 35: goto tr9;
600
- case 37: goto st26;
601
- case 127: goto st0;
602
- }
603
- if ( 0 <= (*p) && (*p) <= 31 )
604
- goto st0;
605
- goto st25;
606
- st26:
607
- if ( ++p == pe )
608
- goto _test_eof26;
609
- case 26:
610
- if ( (*p) < 65 ) {
611
- if ( 48 <= (*p) && (*p) <= 57 )
612
- goto st27;
613
- } else if ( (*p) > 70 ) {
614
- if ( 97 <= (*p) && (*p) <= 102 )
615
- goto st27;
616
- } else
617
- goto st27;
618
- goto st0;
619
- st27:
620
- if ( ++p == pe )
621
- goto _test_eof27;
622
- case 27:
623
- if ( (*p) < 65 ) {
624
- if ( 48 <= (*p) && (*p) <= 57 )
625
- goto st25;
626
- } else if ( (*p) > 70 ) {
627
- if ( 97 <= (*p) && (*p) <= 102 )
628
- goto st25;
629
- } else
630
- goto st25;
631
- goto st0;
632
- tr6:
633
- #line 34 "http11_parser.rl"
634
- {MARK(mark, p); }
635
- goto st28;
636
- st28:
637
- if ( ++p == pe )
638
- goto _test_eof28;
639
- case 28:
640
- #line 641 "http11_parser.c"
641
- switch( (*p) ) {
642
- case 32: goto tr42;
643
- case 35: goto tr43;
644
- case 37: goto st29;
645
- case 59: goto tr45;
646
- case 63: goto tr46;
647
- case 127: goto st0;
648
- }
649
- if ( 0 <= (*p) && (*p) <= 31 )
650
- goto st0;
651
- goto st28;
652
- st29:
653
- if ( ++p == pe )
654
- goto _test_eof29;
655
- case 29:
656
- if ( (*p) < 65 ) {
657
- if ( 48 <= (*p) && (*p) <= 57 )
658
- goto st30;
659
- } else if ( (*p) > 70 ) {
660
- if ( 97 <= (*p) && (*p) <= 102 )
661
- goto st30;
662
- } else
663
- goto st30;
664
- goto st0;
665
- st30:
666
- if ( ++p == pe )
667
- goto _test_eof30;
668
- case 30:
669
- if ( (*p) < 65 ) {
670
- if ( 48 <= (*p) && (*p) <= 57 )
671
- goto st28;
672
- } else if ( (*p) > 70 ) {
673
- if ( 97 <= (*p) && (*p) <= 102 )
674
- goto st28;
675
- } else
676
- goto st28;
677
- goto st0;
678
- tr45:
679
- #line 73 "http11_parser.rl"
680
- {
681
- if(parser->request_path != NULL)
682
- parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
683
- }
684
- goto st31;
685
- st31:
686
- if ( ++p == pe )
687
- goto _test_eof31;
688
- case 31:
689
- #line 690 "http11_parser.c"
690
- switch( (*p) ) {
691
- case 32: goto tr8;
692
- case 35: goto tr9;
693
- case 37: goto st32;
694
- case 63: goto st34;
695
- case 127: goto st0;
696
- }
697
- if ( 0 <= (*p) && (*p) <= 31 )
698
- goto st0;
699
- goto st31;
700
- st32:
701
- if ( ++p == pe )
702
- goto _test_eof32;
703
- case 32:
704
- if ( (*p) < 65 ) {
705
- if ( 48 <= (*p) && (*p) <= 57 )
706
- goto st33;
707
- } else if ( (*p) > 70 ) {
708
- if ( 97 <= (*p) && (*p) <= 102 )
709
- goto st33;
710
- } else
711
- goto st33;
712
- goto st0;
713
- st33:
714
- if ( ++p == pe )
715
- goto _test_eof33;
716
- case 33:
717
- if ( (*p) < 65 ) {
718
- if ( 48 <= (*p) && (*p) <= 57 )
719
- goto st31;
720
- } else if ( (*p) > 70 ) {
721
- if ( 97 <= (*p) && (*p) <= 102 )
722
- goto st31;
723
- } else
724
- goto st31;
725
- goto st0;
726
- tr46:
727
- #line 73 "http11_parser.rl"
728
- {
729
- if(parser->request_path != NULL)
730
- parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
731
- }
732
- goto st34;
733
- st34:
734
- if ( ++p == pe )
735
- goto _test_eof34;
736
- case 34:
737
- #line 738 "http11_parser.c"
738
- switch( (*p) ) {
739
- case 32: goto tr53;
740
- case 35: goto tr54;
741
- case 37: goto tr55;
742
- case 127: goto st0;
743
- }
744
- if ( 0 <= (*p) && (*p) <= 31 )
745
- goto st0;
746
- goto tr52;
747
- tr52:
748
- #line 62 "http11_parser.rl"
749
- {MARK(query_start, p); }
750
- goto st35;
751
- st35:
752
- if ( ++p == pe )
753
- goto _test_eof35;
754
- case 35:
755
- #line 756 "http11_parser.c"
756
- switch( (*p) ) {
757
- case 32: goto tr57;
758
- case 35: goto tr58;
759
- case 37: goto st36;
760
- case 127: goto st0;
761
- }
762
- if ( 0 <= (*p) && (*p) <= 31 )
763
- goto st0;
764
- goto st35;
765
- tr55:
766
- #line 62 "http11_parser.rl"
767
- {MARK(query_start, p); }
768
- goto st36;
769
- st36:
770
- if ( ++p == pe )
771
- goto _test_eof36;
772
- case 36:
773
- #line 774 "http11_parser.c"
774
- if ( (*p) < 65 ) {
775
- if ( 48 <= (*p) && (*p) <= 57 )
776
- goto st37;
777
- } else if ( (*p) > 70 ) {
778
- if ( 97 <= (*p) && (*p) <= 102 )
779
- goto st37;
780
- } else
781
- goto st37;
782
- goto st0;
783
- st37:
784
- if ( ++p == pe )
785
- goto _test_eof37;
786
- case 37:
787
- if ( (*p) < 65 ) {
788
- if ( 48 <= (*p) && (*p) <= 57 )
789
- goto st35;
790
- } else if ( (*p) > 70 ) {
791
- if ( 97 <= (*p) && (*p) <= 102 )
792
- goto st35;
793
- } else
794
- goto st35;
795
- goto st0;
796
- st38:
797
- if ( ++p == pe )
798
- goto _test_eof38;
799
- case 38:
800
- switch( (*p) ) {
801
- case 32: goto tr2;
802
- case 36: goto st39;
803
- case 95: goto st39;
804
- }
805
- if ( (*p) < 48 ) {
806
- if ( 45 <= (*p) && (*p) <= 46 )
807
- goto st39;
808
- } else if ( (*p) > 57 ) {
809
- if ( 65 <= (*p) && (*p) <= 90 )
810
- goto st39;
811
- } else
812
- goto st39;
813
- goto st0;
814
- st39:
815
- if ( ++p == pe )
816
- goto _test_eof39;
817
- case 39:
818
- switch( (*p) ) {
819
- case 32: goto tr2;
820
- case 36: goto st40;
821
- case 95: goto st40;
822
- }
823
- if ( (*p) < 48 ) {
824
- if ( 45 <= (*p) && (*p) <= 46 )
825
- goto st40;
826
- } else if ( (*p) > 57 ) {
827
- if ( 65 <= (*p) && (*p) <= 90 )
828
- goto st40;
829
- } else
830
- goto st40;
831
- goto st0;
832
- st40:
833
- if ( ++p == pe )
834
- goto _test_eof40;
835
- case 40:
836
- switch( (*p) ) {
837
- case 32: goto tr2;
838
- case 36: goto st41;
839
- case 95: goto st41;
840
- }
841
- if ( (*p) < 48 ) {
842
- if ( 45 <= (*p) && (*p) <= 46 )
843
- goto st41;
844
- } else if ( (*p) > 57 ) {
845
- if ( 65 <= (*p) && (*p) <= 90 )
846
- goto st41;
847
- } else
848
- goto st41;
849
- goto st0;
850
- st41:
851
- if ( ++p == pe )
852
- goto _test_eof41;
853
- case 41:
854
- switch( (*p) ) {
855
- case 32: goto tr2;
856
- case 36: goto st42;
857
- case 95: goto st42;
858
- }
859
- if ( (*p) < 48 ) {
860
- if ( 45 <= (*p) && (*p) <= 46 )
861
- goto st42;
862
- } else if ( (*p) > 57 ) {
863
- if ( 65 <= (*p) && (*p) <= 90 )
864
- goto st42;
865
- } else
866
- goto st42;
867
- goto st0;
868
- st42:
869
- if ( ++p == pe )
870
- goto _test_eof42;
871
- case 42:
872
- switch( (*p) ) {
873
- case 32: goto tr2;
874
- case 36: goto st43;
875
- case 95: goto st43;
876
- }
877
- if ( (*p) < 48 ) {
878
- if ( 45 <= (*p) && (*p) <= 46 )
879
- goto st43;
880
- } else if ( (*p) > 57 ) {
881
- if ( 65 <= (*p) && (*p) <= 90 )
882
- goto st43;
883
- } else
884
- goto st43;
885
- goto st0;
886
- st43:
887
- if ( ++p == pe )
888
- goto _test_eof43;
889
- case 43:
890
- switch( (*p) ) {
891
- case 32: goto tr2;
892
- case 36: goto st44;
893
- case 95: goto st44;
894
- }
895
- if ( (*p) < 48 ) {
896
- if ( 45 <= (*p) && (*p) <= 46 )
897
- goto st44;
898
- } else if ( (*p) > 57 ) {
899
- if ( 65 <= (*p) && (*p) <= 90 )
900
- goto st44;
901
- } else
902
- goto st44;
903
- goto st0;
904
- st44:
905
- if ( ++p == pe )
906
- goto _test_eof44;
907
- case 44:
908
- switch( (*p) ) {
909
- case 32: goto tr2;
910
- case 36: goto st45;
911
- case 95: goto st45;
912
- }
913
- if ( (*p) < 48 ) {
914
- if ( 45 <= (*p) && (*p) <= 46 )
915
- goto st45;
916
- } else if ( (*p) > 57 ) {
917
- if ( 65 <= (*p) && (*p) <= 90 )
918
- goto st45;
919
- } else
920
- goto st45;
921
- goto st0;
922
- st45:
923
- if ( ++p == pe )
924
- goto _test_eof45;
925
- case 45:
926
- switch( (*p) ) {
927
- case 32: goto tr2;
928
- case 36: goto st46;
929
- case 95: goto st46;
930
- }
931
- if ( (*p) < 48 ) {
932
- if ( 45 <= (*p) && (*p) <= 46 )
933
- goto st46;
934
- } else if ( (*p) > 57 ) {
935
- if ( 65 <= (*p) && (*p) <= 90 )
936
- goto st46;
937
- } else
938
- goto st46;
939
- goto st0;
940
- st46:
941
- if ( ++p == pe )
942
- goto _test_eof46;
943
- case 46:
944
- switch( (*p) ) {
945
- case 32: goto tr2;
946
- case 36: goto st47;
947
- case 95: goto st47;
948
- }
949
- if ( (*p) < 48 ) {
950
- if ( 45 <= (*p) && (*p) <= 46 )
951
- goto st47;
952
- } else if ( (*p) > 57 ) {
953
- if ( 65 <= (*p) && (*p) <= 90 )
954
- goto st47;
955
- } else
956
- goto st47;
957
- goto st0;
958
- st47:
959
- if ( ++p == pe )
960
- goto _test_eof47;
961
- case 47:
962
- switch( (*p) ) {
963
- case 32: goto tr2;
964
- case 36: goto st48;
965
- case 95: goto st48;
966
- }
967
- if ( (*p) < 48 ) {
968
- if ( 45 <= (*p) && (*p) <= 46 )
969
- goto st48;
970
- } else if ( (*p) > 57 ) {
971
- if ( 65 <= (*p) && (*p) <= 90 )
972
- goto st48;
973
- } else
974
- goto st48;
975
- goto st0;
976
- st48:
977
- if ( ++p == pe )
978
- goto _test_eof48;
979
- case 48:
980
- switch( (*p) ) {
981
- case 32: goto tr2;
982
- case 36: goto st49;
983
- case 95: goto st49;
984
- }
985
- if ( (*p) < 48 ) {
986
- if ( 45 <= (*p) && (*p) <= 46 )
987
- goto st49;
988
- } else if ( (*p) > 57 ) {
989
- if ( 65 <= (*p) && (*p) <= 90 )
990
- goto st49;
991
- } else
992
- goto st49;
993
- goto st0;
994
- st49:
995
- if ( ++p == pe )
996
- goto _test_eof49;
997
- case 49:
998
- switch( (*p) ) {
999
- case 32: goto tr2;
1000
- case 36: goto st50;
1001
- case 95: goto st50;
1002
- }
1003
- if ( (*p) < 48 ) {
1004
- if ( 45 <= (*p) && (*p) <= 46 )
1005
- goto st50;
1006
- } else if ( (*p) > 57 ) {
1007
- if ( 65 <= (*p) && (*p) <= 90 )
1008
- goto st50;
1009
- } else
1010
- goto st50;
1011
- goto st0;
1012
- st50:
1013
- if ( ++p == pe )
1014
- goto _test_eof50;
1015
- case 50:
1016
- switch( (*p) ) {
1017
- case 32: goto tr2;
1018
- case 36: goto st51;
1019
- case 95: goto st51;
1020
- }
1021
- if ( (*p) < 48 ) {
1022
- if ( 45 <= (*p) && (*p) <= 46 )
1023
- goto st51;
1024
- } else if ( (*p) > 57 ) {
1025
- if ( 65 <= (*p) && (*p) <= 90 )
1026
- goto st51;
1027
- } else
1028
- goto st51;
1029
- goto st0;
1030
- st51:
1031
- if ( ++p == pe )
1032
- goto _test_eof51;
1033
- case 51:
1034
- switch( (*p) ) {
1035
- case 32: goto tr2;
1036
- case 36: goto st52;
1037
- case 95: goto st52;
1038
- }
1039
- if ( (*p) < 48 ) {
1040
- if ( 45 <= (*p) && (*p) <= 46 )
1041
- goto st52;
1042
- } else if ( (*p) > 57 ) {
1043
- if ( 65 <= (*p) && (*p) <= 90 )
1044
- goto st52;
1045
- } else
1046
- goto st52;
1047
- goto st0;
1048
- st52:
1049
- if ( ++p == pe )
1050
- goto _test_eof52;
1051
- case 52:
1052
- switch( (*p) ) {
1053
- case 32: goto tr2;
1054
- case 36: goto st53;
1055
- case 95: goto st53;
1056
- }
1057
- if ( (*p) < 48 ) {
1058
- if ( 45 <= (*p) && (*p) <= 46 )
1059
- goto st53;
1060
- } else if ( (*p) > 57 ) {
1061
- if ( 65 <= (*p) && (*p) <= 90 )
1062
- goto st53;
1063
- } else
1064
- goto st53;
1065
- goto st0;
1066
- st53:
1067
- if ( ++p == pe )
1068
- goto _test_eof53;
1069
- case 53:
1070
- switch( (*p) ) {
1071
- case 32: goto tr2;
1072
- case 36: goto st54;
1073
- case 95: goto st54;
1074
- }
1075
- if ( (*p) < 48 ) {
1076
- if ( 45 <= (*p) && (*p) <= 46 )
1077
- goto st54;
1078
- } else if ( (*p) > 57 ) {
1079
- if ( 65 <= (*p) && (*p) <= 90 )
1080
- goto st54;
1081
- } else
1082
- goto st54;
1083
- goto st0;
1084
- st54:
1085
- if ( ++p == pe )
1086
- goto _test_eof54;
1087
- case 54:
1088
- switch( (*p) ) {
1089
- case 32: goto tr2;
1090
- case 36: goto st55;
1091
- case 95: goto st55;
1092
- }
1093
- if ( (*p) < 48 ) {
1094
- if ( 45 <= (*p) && (*p) <= 46 )
1095
- goto st55;
1096
- } else if ( (*p) > 57 ) {
1097
- if ( 65 <= (*p) && (*p) <= 90 )
1098
- goto st55;
1099
- } else
1100
- goto st55;
1101
- goto st0;
1102
- st55:
1103
- if ( ++p == pe )
1104
- goto _test_eof55;
1105
- case 55:
1106
- switch( (*p) ) {
1107
- case 32: goto tr2;
1108
- case 36: goto st56;
1109
- case 95: goto st56;
1110
- }
1111
- if ( (*p) < 48 ) {
1112
- if ( 45 <= (*p) && (*p) <= 46 )
1113
- goto st56;
1114
- } else if ( (*p) > 57 ) {
1115
- if ( 65 <= (*p) && (*p) <= 90 )
1116
- goto st56;
1117
- } else
1118
- goto st56;
1119
- goto st0;
1120
- st56:
1121
- if ( ++p == pe )
1122
- goto _test_eof56;
1123
- case 56:
1124
- if ( (*p) == 32 )
1125
- goto tr2;
1126
- goto st0;
1127
- }
1128
- _test_eof2: cs = 2; goto _test_eof;
1129
- _test_eof3: cs = 3; goto _test_eof;
1130
- _test_eof4: cs = 4; goto _test_eof;
1131
- _test_eof5: cs = 5; goto _test_eof;
1132
- _test_eof6: cs = 6; goto _test_eof;
1133
- _test_eof7: cs = 7; goto _test_eof;
1134
- _test_eof8: cs = 8; goto _test_eof;
1135
- _test_eof9: cs = 9; goto _test_eof;
1136
- _test_eof10: cs = 10; goto _test_eof;
1137
- _test_eof11: cs = 11; goto _test_eof;
1138
- _test_eof12: cs = 12; goto _test_eof;
1139
- _test_eof13: cs = 13; goto _test_eof;
1140
- _test_eof14: cs = 14; goto _test_eof;
1141
- _test_eof15: cs = 15; goto _test_eof;
1142
- _test_eof16: cs = 16; goto _test_eof;
1143
- _test_eof57: cs = 57; goto _test_eof;
1144
- _test_eof17: cs = 17; goto _test_eof;
1145
- _test_eof18: cs = 18; goto _test_eof;
1146
- _test_eof19: cs = 19; goto _test_eof;
1147
- _test_eof20: cs = 20; goto _test_eof;
1148
- _test_eof21: cs = 21; goto _test_eof;
1149
- _test_eof22: cs = 22; goto _test_eof;
1150
- _test_eof23: cs = 23; goto _test_eof;
1151
- _test_eof24: cs = 24; goto _test_eof;
1152
- _test_eof25: cs = 25; goto _test_eof;
1153
- _test_eof26: cs = 26; goto _test_eof;
1154
- _test_eof27: cs = 27; goto _test_eof;
1155
- _test_eof28: cs = 28; goto _test_eof;
1156
- _test_eof29: cs = 29; goto _test_eof;
1157
- _test_eof30: cs = 30; goto _test_eof;
1158
- _test_eof31: cs = 31; goto _test_eof;
1159
- _test_eof32: cs = 32; goto _test_eof;
1160
- _test_eof33: cs = 33; goto _test_eof;
1161
- _test_eof34: cs = 34; goto _test_eof;
1162
- _test_eof35: cs = 35; goto _test_eof;
1163
- _test_eof36: cs = 36; goto _test_eof;
1164
- _test_eof37: cs = 37; goto _test_eof;
1165
- _test_eof38: cs = 38; goto _test_eof;
1166
- _test_eof39: cs = 39; goto _test_eof;
1167
- _test_eof40: cs = 40; goto _test_eof;
1168
- _test_eof41: cs = 41; goto _test_eof;
1169
- _test_eof42: cs = 42; goto _test_eof;
1170
- _test_eof43: cs = 43; goto _test_eof;
1171
- _test_eof44: cs = 44; goto _test_eof;
1172
- _test_eof45: cs = 45; goto _test_eof;
1173
- _test_eof46: cs = 46; goto _test_eof;
1174
- _test_eof47: cs = 47; goto _test_eof;
1175
- _test_eof48: cs = 48; goto _test_eof;
1176
- _test_eof49: cs = 49; goto _test_eof;
1177
- _test_eof50: cs = 50; goto _test_eof;
1178
- _test_eof51: cs = 51; goto _test_eof;
1179
- _test_eof52: cs = 52; goto _test_eof;
1180
- _test_eof53: cs = 53; goto _test_eof;
1181
- _test_eof54: cs = 54; goto _test_eof;
1182
- _test_eof55: cs = 55; goto _test_eof;
1183
- _test_eof56: cs = 56; goto _test_eof;
1184
-
1185
- _test_eof: {}
1186
- _out: {}
1187
- }
1188
- #line 122 "http11_parser.rl"
1189
-
1190
- if (!http_parser_has_error(parser))
1191
- parser->cs = cs;
1192
- parser->nread += p - (buffer + off);
1193
-
1194
- assert(p <= pe && "buffer overflow after parsing execute");
1195
- assert(parser->nread <= len && "nread longer than length");
1196
- assert(parser->body_start <= len && "body starts after buffer end");
1197
- assert(parser->mark < len && "mark is after buffer end");
1198
- assert(parser->field_len <= len && "field has length longer than whole buffer");
1199
- assert(parser->field_start < len && "field starts after buffer end");
1200
-
1201
- return(parser->nread);
1202
- }
1203
-
1204
- int http_parser_finish(http_parser *parser)
1205
- {
1206
- if (http_parser_has_error(parser) ) {
1207
- return -1;
1208
- } else if (http_parser_is_finished(parser) ) {
1209
- return 1;
1210
- } else {
1211
- return 0;
1212
- }
1213
- }
1214
-
1215
- int http_parser_has_error(http_parser *parser) {
1216
- return parser->cs == http_parser_error;
1217
- }
1218
-
1219
- int http_parser_is_finished(http_parser *parser) {
1220
- return parser->cs == http_parser_first_final;
1221
- }