puma 0.8.2-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

Files changed (63) hide show
  1. data/.gemtest +0 -0
  2. data/COPYING +55 -0
  3. data/Gemfile +6 -0
  4. data/History.txt +69 -0
  5. data/LICENSE +26 -0
  6. data/Manifest.txt +60 -0
  7. data/README.md +60 -0
  8. data/Rakefile +12 -0
  9. data/TODO +5 -0
  10. data/bin/puma +15 -0
  11. data/examples/builder.rb +29 -0
  12. data/examples/camping/README +3 -0
  13. data/examples/camping/blog.rb +294 -0
  14. data/examples/camping/tepee.rb +149 -0
  15. data/examples/httpd.conf +474 -0
  16. data/examples/mime.yaml +3 -0
  17. data/examples/mongrel.conf +9 -0
  18. data/examples/monitrc +57 -0
  19. data/examples/random_thrash.rb +19 -0
  20. data/examples/simpletest.rb +52 -0
  21. data/examples/webrick_compare.rb +20 -0
  22. data/ext/puma_http11/PumaHttp11Service.java +13 -0
  23. data/ext/puma_http11/ext_help.h +15 -0
  24. data/ext/puma_http11/extconf.rb +5 -0
  25. data/ext/puma_http11/http11_parser.c +1225 -0
  26. data/ext/puma_http11/http11_parser.h +63 -0
  27. data/ext/puma_http11/http11_parser.java.rl +161 -0
  28. data/ext/puma_http11/http11_parser.rl +146 -0
  29. data/ext/puma_http11/http11_parser_common.rl +54 -0
  30. data/ext/puma_http11/org/jruby/puma/Http11.java +225 -0
  31. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +488 -0
  32. data/ext/puma_http11/puma_http11.c +482 -0
  33. data/lib/puma.rb +18 -0
  34. data/lib/puma/cli.rb +164 -0
  35. data/lib/puma/const.rb +132 -0
  36. data/lib/puma/events.rb +36 -0
  37. data/lib/puma/gems.rb +20 -0
  38. data/lib/puma/mime_types.yml +616 -0
  39. data/lib/puma/rack_patch.rb +22 -0
  40. data/lib/puma/server.rb +429 -0
  41. data/lib/puma/thread_pool.rb +95 -0
  42. data/lib/puma/utils.rb +44 -0
  43. data/lib/puma_http11.jar +0 -0
  44. data/lib/rack/handler/puma.rb +48 -0
  45. data/puma.gemspec +40 -0
  46. data/tasks/gem.rake +24 -0
  47. data/tasks/java.rake +12 -0
  48. data/tasks/native.rake +36 -0
  49. data/tasks/ragel.rake +24 -0
  50. data/test/lobster.ru +4 -0
  51. data/test/mime.yaml +3 -0
  52. data/test/test_cli.rb +19 -0
  53. data/test/test_http10.rb +27 -0
  54. data/test/test_http11.rb +151 -0
  55. data/test/test_persistent.rb +205 -0
  56. data/test/test_rack_handler.rb +10 -0
  57. data/test/test_rack_server.rb +122 -0
  58. data/test/test_thread_pool.rb +102 -0
  59. data/test/test_unix_socket.rb +37 -0
  60. data/test/test_ws.rb +97 -0
  61. data/test/testhelp.rb +41 -0
  62. data/tools/trickletest.rb +45 -0
  63. metadata +163 -0
@@ -0,0 +1,97 @@
1
+ # Copyright (c) 2011 Evan Phoenix
2
+ # Copyright (c) 2005 Zed A. Shaw
3
+
4
+ require 'test/testhelp'
5
+
6
+ include Puma
7
+
8
+ class TestHandler
9
+ attr_reader :ran_test
10
+
11
+ def call(env)
12
+ @ran_test = true
13
+
14
+ [200, {"Content-Type" => "text/plain"}, ["hello!"]]
15
+ end
16
+ end
17
+
18
+ class WebServerTest < Test::Unit::TestCase
19
+
20
+ def setup
21
+ @valid_request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
22
+
23
+ @tester = TestHandler.new
24
+
25
+ @server = Server.new @tester, Events.strings
26
+ @server.add_tcp_listener "127.0.0.1", 9998
27
+
28
+ redirect_test_io do
29
+ @server.run
30
+ end
31
+ end
32
+
33
+ def teardown
34
+ redirect_test_io do
35
+ @server.stop(true)
36
+ end
37
+ end
38
+
39
+ def test_simple_server
40
+ hit(['http://localhost:9998/test'])
41
+ assert @tester.ran_test, "Handler didn't really run"
42
+ end
43
+
44
+
45
+ def do_test(string, chunk, close_after=nil, shutdown_delay=0)
46
+ # Do not use instance variables here, because it needs to be thread safe
47
+ socket = TCPSocket.new("127.0.0.1", 9998);
48
+ request = StringIO.new(string)
49
+ chunks_out = 0
50
+
51
+ while data = request.read(chunk)
52
+ chunks_out += socket.write(data)
53
+ socket.flush
54
+ sleep 0.2
55
+ if close_after and chunks_out > close_after
56
+ socket.close
57
+ sleep 1
58
+ end
59
+ end
60
+ sleep(shutdown_delay)
61
+ socket.write(" ") # Some platforms only raise the exception on attempted write
62
+ socket.flush
63
+ end
64
+
65
+ def test_trickle_attack
66
+ do_test(@valid_request, 3)
67
+ end
68
+
69
+ def test_close_client
70
+ assert_raises IOError do
71
+ do_test(@valid_request, 10, 20)
72
+ end
73
+ end
74
+
75
+ def test_bad_client
76
+ redirect_test_io do
77
+ do_test("GET /test HTTP/BAD", 3)
78
+ end
79
+ end
80
+
81
+ def test_header_is_too_long
82
+ redirect_test_io do
83
+ long = "GET /test HTTP/1.1\r\n" + ("X-Big: stuff\r\n" * 15000) + "\r\n"
84
+ assert_raises Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EINVAL, IOError do
85
+ do_test(long, long.length/2, 10)
86
+ end
87
+ end
88
+ end
89
+
90
+ def test_file_streamed_request
91
+ body = "a" * (Puma::Const::MAX_BODY * 2)
92
+ long = "GET /test HTTP/1.1\r\nContent-length: #{body.length}\r\n\r\n" + body
93
+ do_test(long, Puma::Const::CHUNK_SIZE * 2 -400)
94
+ end
95
+
96
+ end
97
+
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2011 Evan Phoenix
2
+ # Copyright (c) 2005 Zed A. Shaw
3
+
4
+
5
+ %w(lib ext bin test).each do |dir|
6
+ $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
7
+ end
8
+
9
+ require 'rubygems'
10
+ require 'test/unit'
11
+ require 'net/http'
12
+ require 'digest/sha1'
13
+ require 'uri'
14
+ require 'stringio'
15
+
16
+ require 'puma'
17
+
18
+ def redirect_test_io
19
+ yield
20
+ end
21
+
22
+ # Either takes a string to do a get request against, or a tuple of [URI, HTTP] where
23
+ # HTTP is some kind of Net::HTTP request object (POST, HEAD, etc.)
24
+ def hit(uris)
25
+ results = []
26
+ uris.each do |u|
27
+ res = nil
28
+
29
+ if u.kind_of? String
30
+ res = Net::HTTP.get(URI.parse(u))
31
+ else
32
+ url = URI.parse(u[0])
33
+ res = Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }
34
+ end
35
+
36
+ assert res != nil, "Didn't get a response: #{u}"
37
+ results << res
38
+ end
39
+
40
+ return results
41
+ end
@@ -0,0 +1,45 @@
1
+ require 'socket'
2
+ require 'stringio'
3
+
4
+ def do_test(st, chunk)
5
+ s = TCPSocket.new('127.0.0.1',ARGV[0].to_i);
6
+ req = StringIO.new(st)
7
+ nout = 0
8
+ randstop = rand(st.length / 10)
9
+ STDERR.puts "stopping after: #{randstop}"
10
+
11
+ begin
12
+ while data = req.read(chunk)
13
+ nout += s.write(data)
14
+ s.flush
15
+ sleep 0.1
16
+ if nout > randstop
17
+ STDERR.puts "BANG! after #{nout} bytes."
18
+ break
19
+ end
20
+ end
21
+ rescue Object => e
22
+ STDERR.puts "ERROR: #{e}"
23
+ ensure
24
+ s.close
25
+ end
26
+ end
27
+
28
+ content = "-" * (1024 * 240)
29
+ st = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\nContent-Length: #{content.length}\r\n\r\n#{content}"
30
+
31
+ puts "length: #{content.length}"
32
+
33
+ threads = []
34
+ ARGV[1].to_i.times do
35
+ t = Thread.new do
36
+ size = 100
37
+ puts ">>>> #{size} sized chunks"
38
+ do_test(st, size)
39
+ end
40
+
41
+ t.abort_on_exception = true
42
+ threads << t
43
+ end
44
+
45
+ threads.each {|t| t.join}
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puma
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.8.2
6
+ platform: java
7
+ authors:
8
+ - Evan Phoenix
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-11-28 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rack
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: "1.2"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 0.7.0
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: hoe
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: "2.12"
47
+ type: :development
48
+ version_requirements: *id003
49
+ description: |-
50
+ Puma is a small library that provides a very fast and concurrent HTTP 1.1 server for Ruby web applications. It is designed for running rack apps only.
51
+
52
+ What makes Puma so fast is the careful use of an Ragel extension to provide fast, accurate HTTP 1.1 protocol parsing. This makes the server scream without too many portability issues.
53
+ email:
54
+ - evan@phx.io
55
+ executables:
56
+ - puma
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - History.txt
61
+ - Manifest.txt
62
+ files:
63
+ - COPYING
64
+ - Gemfile
65
+ - History.txt
66
+ - LICENSE
67
+ - Manifest.txt
68
+ - README.md
69
+ - Rakefile
70
+ - TODO
71
+ - bin/puma
72
+ - examples/builder.rb
73
+ - examples/camping/README
74
+ - examples/camping/blog.rb
75
+ - examples/camping/tepee.rb
76
+ - examples/httpd.conf
77
+ - examples/mime.yaml
78
+ - examples/mongrel.conf
79
+ - examples/monitrc
80
+ - examples/random_thrash.rb
81
+ - examples/simpletest.rb
82
+ - examples/webrick_compare.rb
83
+ - ext/puma_http11/PumaHttp11Service.java
84
+ - ext/puma_http11/ext_help.h
85
+ - ext/puma_http11/extconf.rb
86
+ - ext/puma_http11/http11_parser.c
87
+ - ext/puma_http11/http11_parser.h
88
+ - ext/puma_http11/http11_parser.java.rl
89
+ - ext/puma_http11/http11_parser.rl
90
+ - ext/puma_http11/http11_parser_common.rl
91
+ - ext/puma_http11/org/jruby/puma/Http11.java
92
+ - ext/puma_http11/org/jruby/puma/Http11Parser.java
93
+ - ext/puma_http11/puma_http11.c
94
+ - lib/puma.rb
95
+ - lib/puma/cli.rb
96
+ - lib/puma/const.rb
97
+ - lib/puma/events.rb
98
+ - lib/puma/gems.rb
99
+ - lib/puma/mime_types.yml
100
+ - lib/puma/rack_patch.rb
101
+ - lib/puma/server.rb
102
+ - lib/puma/thread_pool.rb
103
+ - lib/puma/utils.rb
104
+ - lib/rack/handler/puma.rb
105
+ - puma.gemspec
106
+ - tasks/gem.rake
107
+ - tasks/java.rake
108
+ - tasks/native.rake
109
+ - tasks/ragel.rake
110
+ - test/lobster.ru
111
+ - test/mime.yaml
112
+ - test/test_cli.rb
113
+ - test/test_http10.rb
114
+ - test/test_http11.rb
115
+ - test/test_persistent.rb
116
+ - test/test_rack_handler.rb
117
+ - test/test_rack_server.rb
118
+ - test/test_thread_pool.rb
119
+ - test/test_unix_socket.rb
120
+ - test/test_ws.rb
121
+ - test/testhelp.rb
122
+ - tools/trickletest.rb
123
+ - .gemtest
124
+ - lib/puma_http11.jar
125
+ has_rdoc: true
126
+ homepage:
127
+ licenses: []
128
+
129
+ post_install_message:
130
+ rdoc_options:
131
+ - --main
132
+ - README.md
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: "0"
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: "0"
147
+ requirements: []
148
+
149
+ rubyforge_project: puma
150
+ rubygems_version: 1.5.1
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Puma is a small library that provides a very fast and concurrent HTTP 1.1 server for Ruby web applications
154
+ test_files:
155
+ - test/test_cli.rb
156
+ - test/test_http10.rb
157
+ - test/test_http11.rb
158
+ - test/test_persistent.rb
159
+ - test/test_rack_handler.rb
160
+ - test/test_rack_server.rb
161
+ - test/test_thread_pool.rb
162
+ - test/test_unix_socket.rb
163
+ - test/test_ws.rb