unicorn 4.8.0 → 6.1.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.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.document +0 -1
  3. data/.gitattributes +5 -0
  4. data/.gitignore +2 -2
  5. data/.manifest +17 -21
  6. data/.olddoc.yml +25 -0
  7. data/Application_Timeouts +7 -7
  8. data/CONTRIBUTORS +6 -2
  9. data/DESIGN +2 -4
  10. data/Documentation/.gitignore +1 -3
  11. data/Documentation/unicorn.1 +222 -0
  12. data/Documentation/unicorn_rails.1 +207 -0
  13. data/FAQ +23 -6
  14. data/GIT-VERSION-FILE +1 -1
  15. data/GIT-VERSION-GEN +1 -1
  16. data/GNUmakefile +138 -92
  17. data/HACKING +10 -32
  18. data/ISSUES +80 -19
  19. data/KNOWN_ISSUES +18 -18
  20. data/LATEST +23 -27
  21. data/LICENSE +2 -2
  22. data/Links +24 -22
  23. data/NEWS +823 -0
  24. data/PHILOSOPHY +0 -6
  25. data/README +49 -48
  26. data/Rakefile +0 -44
  27. data/SIGNALS +2 -2
  28. data/Sandbox +11 -10
  29. data/TODO +0 -2
  30. data/TUNING +30 -9
  31. data/archive/.gitignore +3 -0
  32. data/archive/slrnpull.conf +4 -0
  33. data/bin/unicorn +4 -2
  34. data/bin/unicorn_rails +3 -3
  35. data/examples/big_app_gc.rb +1 -1
  36. data/examples/init.sh +36 -8
  37. data/examples/logrotate.conf +17 -2
  38. data/examples/nginx.conf +14 -14
  39. data/examples/unicorn.conf.minimal.rb +2 -2
  40. data/examples/unicorn.conf.rb +14 -6
  41. data/examples/unicorn.socket +11 -0
  42. data/examples/unicorn@.service +40 -0
  43. data/ext/unicorn_http/c_util.h +5 -13
  44. data/ext/unicorn_http/common_field_optimization.h +22 -5
  45. data/ext/unicorn_http/epollexclusive.h +124 -0
  46. data/ext/unicorn_http/ext_help.h +0 -44
  47. data/ext/unicorn_http/extconf.rb +32 -5
  48. data/ext/unicorn_http/global_variables.h +2 -2
  49. data/ext/unicorn_http/httpdate.c +3 -2
  50. data/ext/unicorn_http/unicorn_http.c +926 -638
  51. data/ext/unicorn_http/unicorn_http.rl +159 -170
  52. data/ext/unicorn_http/unicorn_http_common.rl +1 -1
  53. data/lib/unicorn/configurator.rb +110 -46
  54. data/lib/unicorn/const.rb +2 -25
  55. data/lib/unicorn/http_request.rb +110 -31
  56. data/lib/unicorn/http_response.rb +17 -31
  57. data/lib/unicorn/http_server.rb +272 -180
  58. data/lib/unicorn/launcher.rb +1 -1
  59. data/lib/unicorn/oob_gc.rb +16 -6
  60. data/lib/unicorn/select_waiter.rb +6 -0
  61. data/lib/unicorn/socket_helper.rb +58 -78
  62. data/lib/unicorn/stream_input.rb +8 -7
  63. data/lib/unicorn/tee_input.rb +16 -11
  64. data/lib/unicorn/tmpio.rb +10 -6
  65. data/lib/unicorn/util.rb +5 -4
  66. data/lib/unicorn/version.rb +1 -1
  67. data/lib/unicorn/worker.rb +36 -23
  68. data/lib/unicorn.rb +64 -44
  69. data/man/man1/unicorn.1 +124 -122
  70. data/man/man1/unicorn_rails.1 +113 -127
  71. data/t/.gitignore +0 -1
  72. data/t/GNUmakefile +3 -80
  73. data/t/README +4 -4
  74. data/t/t0002-parser-error.sh +3 -3
  75. data/t/t0011-active-unix-socket.sh +1 -1
  76. data/t/t0012-reload-empty-config.sh +2 -1
  77. data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
  78. data/t/t0301.ru +13 -0
  79. data/t/test-lib.sh +4 -3
  80. data/test/benchmark/README +14 -4
  81. data/test/benchmark/ddstream.ru +50 -0
  82. data/test/benchmark/readinput.ru +40 -0
  83. data/test/benchmark/uconnect.perl +66 -0
  84. data/test/exec/test_exec.rb +74 -20
  85. data/test/test_helper.rb +42 -33
  86. data/test/unit/test_ccc.rb +91 -0
  87. data/test/unit/test_droplet.rb +1 -1
  88. data/test/unit/test_http_parser.rb +49 -19
  89. data/test/unit/test_http_parser_ng.rb +98 -115
  90. data/test/unit/test_request.rb +11 -11
  91. data/test/unit/test_response.rb +31 -19
  92. data/test/unit/test_server.rb +89 -15
  93. data/test/unit/test_signals.rb +9 -9
  94. data/test/unit/test_socket_helper.rb +16 -12
  95. data/test/unit/test_tee_input.rb +10 -0
  96. data/test/unit/test_upload.rb +10 -15
  97. data/test/unit/test_util.rb +32 -6
  98. data/test/unit/test_waiter.rb +34 -0
  99. data/unicorn.gemspec +28 -23
  100. data/unicorn_1 +1 -0
  101. data/unicorn_rails_1 +1 -0
  102. metadata +68 -134
  103. data/.wrongdoc.yml +0 -10
  104. data/ChangeLog +0 -4861
  105. data/Documentation/GNUmakefile +0 -30
  106. data/Documentation/unicorn.1.txt +0 -178
  107. data/Documentation/unicorn_rails.1.txt +0 -175
  108. data/examples/git.ru +0 -13
  109. data/lib/unicorn/app/exec_cgi.rb +0 -154
  110. data/lib/unicorn/app/inetd.rb +0 -109
  111. data/lib/unicorn/ssl_client.rb +0 -11
  112. data/lib/unicorn/ssl_configurator.rb +0 -104
  113. data/lib/unicorn/ssl_server.rb +0 -42
  114. data/local.mk.sample +0 -59
  115. data/script/isolate_for_tests +0 -32
  116. data/t/hijack.ru +0 -42
  117. data/t/sslgen.sh +0 -71
  118. data/t/t0016-trust-x-forwarded-false.sh +0 -30
  119. data/t/t0017-trust-x-forwarded-true.sh +0 -30
  120. data/t/t0200-rack-hijack.sh +0 -27
  121. data/t/t0600-https-server-basic.sh +0 -48
  122. data/test/unit/test_http_parser_xftrust.rb +0 -38
  123. data/test/unit/test_sni_hostnames.rb +0 -47
@@ -1,104 +0,0 @@
1
- # -*- encoding: binary -*-
2
- # :stopdoc:
3
- # This module is included in Unicorn::Configurator
4
- # :startdoc:
5
- #
6
- module Unicorn::SSLConfigurator
7
- def ssl(&block)
8
- ssl_require!
9
- before = @set[:listeners].dup
10
- opts = @set[:ssl_opts] = {}
11
- yield
12
- (@set[:listeners] - before).each do |address|
13
- (@set[:listener_opts][address] ||= {})[:ssl_opts] = opts
14
- end
15
- ensure
16
- @set.delete(:ssl_opts)
17
- end
18
-
19
- def ssl_certificate(file)
20
- ssl_set(:ssl_certificate, file)
21
- end
22
-
23
- def ssl_certificate_key(file)
24
- ssl_set(:ssl_certificate_key, file)
25
- end
26
-
27
- def ssl_client_certificate(file)
28
- ssl_set(:ssl_client_certificate, file)
29
- end
30
-
31
- def ssl_dhparam(file)
32
- ssl_set(:ssl_dhparam, file)
33
- end
34
-
35
- def ssl_ciphers(openssl_cipherlist_spec)
36
- ssl_set(:ssl_ciphers, openssl_cipherlist_spec)
37
- end
38
-
39
- def ssl_crl(file)
40
- ssl_set(:ssl_crl, file)
41
- end
42
-
43
- def ssl_prefer_server_ciphers(bool)
44
- ssl_set(:ssl_prefer_server_ciphers, check_bool(bool))
45
- end
46
-
47
- def ssl_protocols(list)
48
- ssl_set(:ssl_protocols, list)
49
- end
50
-
51
- def ssl_verify_client(on_off_optional)
52
- ssl_set(:ssl_verify_client, on_off_optional)
53
- end
54
-
55
- def ssl_session_timeout(seconds)
56
- ssl_set(:ssl_session_timeout, seconds)
57
- end
58
-
59
- def ssl_verify_depth(depth)
60
- ssl_set(:ssl_verify_depth, depth)
61
- end
62
-
63
- # Allows specifying an engine for OpenSSL to use. We have not been
64
- # able to successfully test this feature due to a lack of hardware,
65
- # Reports of success or patches to mongrel-unicorn@rubyforge.org is
66
- # greatly appreciated.
67
- def ssl_engine(engine)
68
- ssl_warn_global(:ssl_engine)
69
- ssl_require!
70
- OpenSSL::Engine.load
71
- OpenSSL::Engine.by_id(engine)
72
- @set[:ssl_engine] = engine
73
- end
74
-
75
- def ssl_compression(bool)
76
- # OpenSSL uses the SSL_OP_NO_COMPRESSION flag, Flipper follows suit
77
- # with :ssl_no_compression, but we negate it to avoid exposing double
78
- # negatives to the user.
79
- ssl_set(:ssl_no_compression, check_bool(:ssl_compression, ! bool))
80
- end
81
-
82
- private
83
-
84
- def ssl_warn_global(func) # :nodoc:
85
- Hash === @set[:ssl_opts] or return
86
- warn("`#{func}' affects all SSL contexts in this process, " \
87
- "not just this block")
88
- end
89
-
90
- def ssl_set(key, value) # :nodoc:
91
- cur = @set[:ssl_opts]
92
- Hash === cur or
93
- raise ArgumentError, "#{key} must be called inside an `ssl' block"
94
- cur[key] = value
95
- end
96
-
97
- def ssl_require! # :nodoc:
98
- require "flipper"
99
- require "unicorn/ssl_client"
100
- rescue LoadError
101
- warn "install 'kgio-monkey' for SSL support"
102
- raise
103
- end
104
- end
@@ -1,42 +0,0 @@
1
- # -*- encoding: binary -*-
2
- # :stopdoc:
3
- # this module is meant to be included in Unicorn::HttpServer
4
- # It is an implementation detail and NOT meant for users.
5
- module Unicorn::SSLServer
6
- attr_accessor :ssl_engine
7
-
8
- def ssl_enable!
9
- sni_hostnames = rack_sni_hostnames(@app)
10
- seen = {} # we map a single SSLContext to multiple listeners
11
- listener_ctx = {}
12
- @listener_opts.each do |address, address_opts|
13
- ssl_opts = address_opts[:ssl_opts] or next
14
- listener_ctx[address] = seen[ssl_opts.object_id] ||= begin
15
- unless sni_hostnames.empty?
16
- ssl_opts = ssl_opts.dup
17
- ssl_opts[:sni_hostnames] = sni_hostnames
18
- end
19
- ctx = Flipper.ssl_context(ssl_opts)
20
- # FIXME: make configurable
21
- ctx.session_cache_mode = OpenSSL::SSL::SSLContext::SESSION_CACHE_OFF
22
- ctx
23
- end
24
- end
25
- Unicorn::HttpServer::LISTENERS.each do |listener|
26
- ctx = listener_ctx[sock_name(listener)] or next
27
- listener.extend(Kgio::SSLServer)
28
- listener.ssl_ctx = ctx
29
- listener.kgio_ssl_class = Unicorn::SSLClient
30
- end
31
- end
32
-
33
- # ugh, this depends on Rack internals...
34
- def rack_sni_hostnames(rack_app) # :nodoc:
35
- hostnames = {}
36
- if Rack::URLMap === rack_app
37
- mapping = rack_app.instance_variable_get(:@mapping)
38
- mapping.each { |hostname,_,_,_| hostnames[hostname] = true }
39
- end
40
- hostnames.keys
41
- end
42
- end
data/local.mk.sample DELETED
@@ -1,59 +0,0 @@
1
- # this is the local.mk file used by Eric Wong on his dev boxes.
2
- # GNUmakefile will source local.mk in the top-level source tree
3
- # if it is present.
4
- #
5
- # This is depends on a bunch of GNU-isms from bash, sed, touch.
6
-
7
- DLEXT := so
8
-
9
- # Avoid loading rubygems to speed up tests because gmake is
10
- # fork+exec heavy with Ruby.
11
- prefix = $(HOME)
12
-
13
- # XXX clean this up
14
- ifeq ($(r192),)
15
- ifeq ($(r19),)
16
- ifeq ($(rbx),)
17
- ifeq ($(r186),)
18
- RUBY := $(prefix)/bin/ruby
19
- else
20
- prefix := $(prefix)/r186-p114
21
- export PATH := $(prefix)/bin:$(PATH)
22
- RUBY := $(prefix)/bin/ruby
23
- endif
24
- else
25
- prefix := $(prefix)/rbx
26
- export PATH := $(prefix)/bin:$(PATH)
27
- RUBY := $(prefix)/bin/rbx
28
- endif
29
- else
30
- prefix := $(prefix)/ruby-1.9
31
- export PATH := $(prefix)/bin:$(PATH)
32
- RUBY := $(prefix)/bin/ruby --disable-gems
33
- endif
34
- else
35
- prefix := $(prefix)/ruby-1.9.2
36
- export PATH := $(prefix)/bin:$(PATH)
37
- RUBY := $(prefix)/bin/ruby --disable-gems
38
- endif
39
-
40
- # pipefail is THE reason to use bash (v3+) or never revisions of ksh93
41
- # SHELL := /bin/bash -e -o pipefail
42
- SHELL := /bin/ksh93 -e -o pipefail
43
-
44
- full-test: test-18 test-191 test-192 test-rbx test-186
45
-
46
- # FIXME: keep eye on Rubinius activity and wait for fixes from upstream
47
- # so we don't need RBX_SKIP anymore
48
- test-rbx: export RBX_SKIP := 1
49
- test-rbx: export RUBY := $(RUBY)
50
- test-rbx:
51
- $(MAKE) test test-integration rbx=T 2>&1 |sed -e 's!^!rbx !'
52
- test-186:
53
- $(MAKE) test-all r186=1 2>&1 |sed 's!^!1.8.6 !'
54
- test-18:
55
- $(MAKE) test-all 2>&1 |sed 's!^!1.8 !'
56
- test-191:
57
- $(MAKE) test-all r19=1 2>&1 |sed 's!^!1.9.1 !'
58
- test-192:
59
- $(MAKE) test-all r192=1 2>&1 |sed 's!^!1.9.2 !'
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # scripts/Makefiles can read and eval the output of this script and
3
- # use it as RUBYLIB
4
- require 'rubygems'
5
- require 'isolate'
6
- fp = File.open(__FILE__, "rb")
7
- fp.flock(File::LOCK_EX)
8
-
9
- ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
10
- opts = {
11
- :system => false,
12
- # we want "ruby-1.8.7" and not "ruby-1.8", so disable :multiruby
13
- :multiruby => false,
14
- :path => "tmp/isolate/#{ruby_engine}-#{RUBY_VERSION}",
15
- }
16
-
17
- pid = fork do
18
- Isolate.now!(opts) do
19
- gem 'raindrops', '0.12.0'
20
- gem 'kgio-monkey', '0.4.0'
21
- gem 'kgio', '2.8.1'
22
- gem 'rack', '1.5.2'
23
- end
24
- end
25
- _, status = Process.waitpid2(pid)
26
- status.success? or abort status.inspect
27
- lib_paths = Dir["#{opts[:path]}/gems/*-*/lib"].map { |x| File.expand_path(x) }
28
- dst = "tmp/isolate/#{ruby_engine}-#{RUBY_VERSION}.mk"
29
- File.open("#{dst}.#$$", "w") do |fp|
30
- fp.puts "ISOLATE_LIBS=#{lib_paths.join(':')}"
31
- end
32
- File.rename("#{dst}.#$$", dst)
data/t/hijack.ru DELETED
@@ -1,42 +0,0 @@
1
- use Rack::Lint
2
- use Rack::ContentLength
3
- use Rack::ContentType, "text/plain"
4
- class DieIfUsed
5
- def each
6
- abort "body.each called after response hijack\n"
7
- end
8
-
9
- def close
10
- abort "body.close called after response hijack\n"
11
- end
12
- end
13
- run lambda { |env|
14
- case env["PATH_INFO"]
15
- when "/hijack_req"
16
- if env["rack.hijack?"]
17
- io = env["rack.hijack"].call
18
- if io.respond_to?(:read_nonblock) &&
19
- env["rack.hijack_io"].respond_to?(:read_nonblock)
20
-
21
- # exercise both, since we Rack::Lint may use different objects
22
- env["rack.hijack_io"].write("HTTP/1.0 200 OK\r\n\r\n")
23
- io.write("request.hijacked")
24
- io.close
25
- return [ 500, {}, DieIfUsed.new ]
26
- end
27
- end
28
- [ 500, {}, [ "hijack BAD\n" ] ]
29
- when "/hijack_res"
30
- r = "response.hijacked"
31
- [ 200,
32
- {
33
- "Content-Length" => r.bytesize.to_s,
34
- "rack.hijack" => proc do |io|
35
- io.write(r)
36
- io.close
37
- end
38
- },
39
- DieIfUsed.new
40
- ]
41
- end
42
- }
data/t/sslgen.sh DELETED
@@ -1,71 +0,0 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- lock=$0.lock
5
- while ! mkdir $lock 2>/dev/null
6
- do
7
- echo >&2 "PID=$$ waiting for $lock"
8
- sleep 1
9
- done
10
- pid=$$
11
- trap 'if test $$ -eq $pid; then rmdir $lock; fi' EXIT
12
-
13
- certinfo() {
14
- echo US
15
- echo Hell
16
- echo A Very Special Place
17
- echo Monkeys
18
- echo Poo-Flingers
19
- echo 127.0.0.1
20
- echo kgio@bogomips.org
21
- }
22
-
23
- certinfo2() {
24
- certinfo
25
- echo
26
- echo
27
- }
28
-
29
- ca_certinfo () {
30
- echo US
31
- echo Hell
32
- echo An Even More Special Place
33
- echo Deranged Monkeys
34
- echo Poo-Hurlers
35
- echo 127.6.6.6
36
- echo unicorn@bogomips.org
37
- }
38
-
39
- openssl genrsa -out ca.key 1024
40
- ca_certinfo | openssl req -new -x509 -days 666 -key ca.key -out ca.crt
41
-
42
- openssl genrsa -out bad-ca.key 1024
43
- ca_certinfo | openssl req -new -x509 -days 666 -key bad-ca.key -out bad-ca.crt
44
-
45
- openssl genrsa -out server.key 1024
46
- certinfo2 | openssl req -new -key server.key -out server.csr
47
-
48
- openssl x509 -req -days 666 \
49
- -in server.csr -CA ca.crt -CAkey ca.key -set_serial 1 -out server.crt
50
- n=2
51
- mk_client_cert () {
52
- CLIENT=$1
53
- openssl genrsa -out $CLIENT.key 1024
54
- certinfo2 | openssl req -new -key $CLIENT.key -out $CLIENT.csr
55
-
56
- openssl x509 -req -days 666 \
57
- -in $CLIENT.csr -CA $CA.crt -CAkey $CA.key -set_serial $n \
58
- -out $CLIENT.crt
59
- rm -f $CLIENT.csr
60
- n=$(($n + 1))
61
- }
62
-
63
- CA=ca
64
- mk_client_cert client1
65
- mk_client_cert client2
66
-
67
- CA=bad-ca mk_client_cert bad-client
68
-
69
- rm -f server.csr
70
-
71
- echo OK
@@ -1,30 +0,0 @@
1
- #!/bin/sh
2
- . ./test-lib.sh
3
- t_plan 5 "trust_x_forwarded=false configuration test"
4
-
5
- t_begin "setup and start" && {
6
- unicorn_setup
7
- echo "trust_x_forwarded false" >> $unicorn_config
8
- unicorn -D -c $unicorn_config env.ru
9
- unicorn_wait_start
10
- }
11
-
12
- t_begin "spoofed request with X-Forwarded-Proto does not trigger" && {
13
- curl -H 'X-Forwarded-Proto: https' http://$listen/ | \
14
- grep -F '"rack.url_scheme"=>"http"'
15
- }
16
-
17
- t_begin "spoofed request with X-Forwarded-SSL does not trigger" && {
18
- curl -H 'X-Forwarded-SSL: on' http://$listen/ | \
19
- grep -F '"rack.url_scheme"=>"http"'
20
- }
21
-
22
- t_begin "killing succeeds" && {
23
- kill $unicorn_pid
24
- }
25
-
26
- t_begin "check stderr has no errors" && {
27
- check_stderr
28
- }
29
-
30
- t_done
@@ -1,30 +0,0 @@
1
- #!/bin/sh
2
- . ./test-lib.sh
3
- t_plan 5 "trust_x_forwarded=true configuration test"
4
-
5
- t_begin "setup and start" && {
6
- unicorn_setup
7
- echo "trust_x_forwarded true " >> $unicorn_config
8
- unicorn -D -c $unicorn_config env.ru
9
- unicorn_wait_start
10
- }
11
-
12
- t_begin "spoofed request with X-Forwarded-Proto sets 'https'" && {
13
- curl -H 'X-Forwarded-Proto: https' http://$listen/ | \
14
- grep -F '"rack.url_scheme"=>"https"'
15
- }
16
-
17
- t_begin "spoofed request with X-Forwarded-SSL sets 'https'" && {
18
- curl -H 'X-Forwarded-SSL: on' http://$listen/ | \
19
- grep -F '"rack.url_scheme"=>"https"'
20
- }
21
-
22
- t_begin "killing succeeds" && {
23
- kill $unicorn_pid
24
- }
25
-
26
- t_begin "check stderr has no errors" && {
27
- check_stderr
28
- }
29
-
30
- t_done
@@ -1,27 +0,0 @@
1
- #!/bin/sh
2
- . ./test-lib.sh
3
- t_plan 5 "rack.hijack tests (Rack 1.5+ (Rack::VERSION >= [ 1,2]))"
4
-
5
- t_begin "setup and start" && {
6
- unicorn_setup
7
- unicorn -D -c $unicorn_config hijack.ru
8
- unicorn_wait_start
9
- }
10
-
11
- t_begin "check request hijack" && {
12
- test "xrequest.hijacked" = x"$(curl -sSfv http://$listen/hijack_req)"
13
- }
14
-
15
- t_begin "check response hijack" && {
16
- test "xresponse.hijacked" = x"$(curl -sSfv http://$listen/hijack_res)"
17
- }
18
-
19
- t_begin "killing succeeds" && {
20
- kill $unicorn_pid
21
- }
22
-
23
- t_begin "check stderr" && {
24
- check_stderr
25
- }
26
-
27
- t_done
@@ -1,48 +0,0 @@
1
- #!/bin/sh
2
- . ./test-lib.sh
3
- t_plan 7 "simple HTTPS connection tests"
4
-
5
- t_begin "setup and start" && {
6
- rtmpfiles curl_err
7
- unicorn_setup
8
- cat > $unicorn_config <<EOF
9
- ssl do
10
- listen "$listen"
11
- ssl_certificate "server.crt"
12
- ssl_certificate_key "server.key"
13
- end
14
- pid "$pid"
15
- stderr_path "$r_err"
16
- stdout_path "$r_out"
17
- EOF
18
- unicorn -D -c $unicorn_config env.ru
19
- unicorn_wait_start
20
- }
21
-
22
- t_begin "single request" && {
23
- curl -sSfv --cacert ca.crt https://$listen/
24
- }
25
-
26
- t_begin "check stderr has no errors" && {
27
- check_stderr
28
- }
29
-
30
- t_begin "multiple requests" && {
31
- curl -sSfv --no-keepalive --cacert ca.crt \
32
- https://$listen/ https://$listen/ 2>> $curl_err >> $tmp
33
- dbgcat curl_err
34
- }
35
-
36
- t_begin "check stderr has no errors" && {
37
- check_stderr
38
- }
39
-
40
- t_begin "killing succeeds" && {
41
- kill $unicorn_pid
42
- }
43
-
44
- t_begin "check stderr has no errors" && {
45
- check_stderr
46
- }
47
-
48
- t_done
@@ -1,38 +0,0 @@
1
- # -*- encoding: binary -*-
2
- require 'test/test_helper'
3
-
4
- include Unicorn
5
-
6
- class HttpParserXFTrustTest < Test::Unit::TestCase
7
- def setup
8
- assert HttpParser.trust_x_forwarded?
9
- end
10
-
11
- def test_xf_trust_false_xfp
12
- HttpParser.trust_x_forwarded = false
13
- parser = HttpParser.new
14
- parser.buf << "GET / HTTP/1.1\r\nHost: foo:\r\n" \
15
- "X-Forwarded-Proto: https\r\n\r\n"
16
- env = parser.parse
17
- assert_kind_of Hash, env
18
- assert_equal 'foo', env['SERVER_NAME']
19
- assert_equal '80', env['SERVER_PORT']
20
- assert_equal 'http', env['rack.url_scheme']
21
- end
22
-
23
- def test_xf_trust_false_xfs
24
- HttpParser.trust_x_forwarded = false
25
- parser = HttpParser.new
26
- parser.buf << "GET / HTTP/1.1\r\nHost: foo:\r\n" \
27
- "X-Forwarded-SSL: on\r\n\r\n"
28
- env = parser.parse
29
- assert_kind_of Hash, env
30
- assert_equal 'foo', env['SERVER_NAME']
31
- assert_equal '80', env['SERVER_PORT']
32
- assert_equal 'http', env['rack.url_scheme']
33
- end
34
-
35
- def teardown
36
- HttpParser.trust_x_forwarded = true
37
- end
38
- end
@@ -1,47 +0,0 @@
1
- # -*- encoding: binary -*-
2
- require "test/unit"
3
- require "unicorn"
4
-
5
- # this tests an implementation detail, it may change so this test
6
- # can be removed later.
7
- class TestSniHostnames < Test::Unit::TestCase
8
- include Unicorn::SSLServer
9
-
10
- def setup
11
- GC.start
12
- end
13
-
14
- def teardown
15
- GC.start
16
- end
17
-
18
- def test_host_name_detect_one
19
- app = Rack::Builder.new do
20
- map "http://sni1.example.com/" do
21
- use Rack::ContentLength
22
- use Rack::ContentType, "text/plain"
23
- run lambda { |env| [ 200, {}, [] ] }
24
- end
25
- end.to_app
26
- hostnames = rack_sni_hostnames(app)
27
- assert hostnames.include?("sni1.example.com")
28
- end
29
-
30
- def test_host_name_detect_multiple
31
- app = Rack::Builder.new do
32
- map "http://sni2.example.com/" do
33
- use Rack::ContentLength
34
- use Rack::ContentType, "text/plain"
35
- run lambda { |env| [ 200, {}, [] ] }
36
- end
37
- map "http://sni3.example.com/" do
38
- use Rack::ContentLength
39
- use Rack::ContentType, "text/plain"
40
- run lambda { |env| [ 200, {}, [] ] }
41
- end
42
- end.to_app
43
- hostnames = rack_sni_hostnames(app)
44
- assert hostnames.include?("sni2.example.com")
45
- assert hostnames.include?("sni3.example.com")
46
- end
47
- end