preplay_unicorn 4.3.1.2.gc450
Sign up to get free protection for your applications and to get access to all the features.
- data/.CHANGELOG.old +25 -0
- data/.document +29 -0
- data/.gitignore +24 -0
- data/.mailmap +26 -0
- data/.manifest +258 -0
- data/.wrongdoc.yml +10 -0
- data/Application_Timeouts +77 -0
- data/CONTRIBUTORS +35 -0
- data/COPYING +674 -0
- data/ChangeLog +3839 -0
- data/DESIGN +97 -0
- data/Documentation/.gitignore +5 -0
- data/Documentation/GNUmakefile +30 -0
- data/Documentation/unicorn.1.txt +174 -0
- data/Documentation/unicorn_rails.1.txt +175 -0
- data/FAQ +53 -0
- data/GIT-VERSION-FILE +1 -0
- data/GIT-VERSION-GEN +40 -0
- data/GNUmakefile +294 -0
- data/HACKING +134 -0
- data/ISSUES +36 -0
- data/KNOWN_ISSUES +79 -0
- data/LATEST +15 -0
- data/LICENSE +64 -0
- data/Links +56 -0
- data/NEWS +1886 -0
- data/PHILOSOPHY +145 -0
- data/README +149 -0
- data/Rakefile +97 -0
- data/SIGNALS +114 -0
- data/Sandbox +96 -0
- data/TODO +5 -0
- data/TUNING +98 -0
- data/bin/unicorn +121 -0
- data/bin/unicorn_rails +209 -0
- data/examples/big_app_gc.rb +2 -0
- data/examples/echo.ru +27 -0
- data/examples/git.ru +13 -0
- data/examples/init.sh +74 -0
- data/examples/logger_mp_safe.rb +25 -0
- data/examples/logrotate.conf +29 -0
- data/examples/nginx.conf +156 -0
- data/examples/unicorn.conf.minimal.rb +13 -0
- data/examples/unicorn.conf.rb +94 -0
- data/ext/unicorn_http/CFLAGS +13 -0
- data/ext/unicorn_http/c_util.h +124 -0
- data/ext/unicorn_http/common_field_optimization.h +111 -0
- data/ext/unicorn_http/ext_help.h +86 -0
- data/ext/unicorn_http/extconf.rb +10 -0
- data/ext/unicorn_http/global_variables.h +97 -0
- data/ext/unicorn_http/httpdate.c +82 -0
- data/ext/unicorn_http/unicorn_http.c +4031 -0
- data/ext/unicorn_http/unicorn_http.rl +1036 -0
- data/ext/unicorn_http/unicorn_http_common.rl +76 -0
- data/lib/unicorn/app/exec_cgi.rb +154 -0
- data/lib/unicorn/app/inetd.rb +109 -0
- data/lib/unicorn/app/old_rails/static.rb +59 -0
- data/lib/unicorn/app/old_rails.rb +35 -0
- data/lib/unicorn/cgi_wrapper.rb +147 -0
- data/lib/unicorn/configurator.rb +641 -0
- data/lib/unicorn/const.rb +40 -0
- data/lib/unicorn/http_request.rb +77 -0
- data/lib/unicorn/http_response.rb +45 -0
- data/lib/unicorn/http_server.rb +748 -0
- data/lib/unicorn/launcher.rb +62 -0
- data/lib/unicorn/oob_gc.rb +71 -0
- data/lib/unicorn/preread_input.rb +33 -0
- data/lib/unicorn/socket_helper.rb +208 -0
- data/lib/unicorn/ssl_client.rb +11 -0
- data/lib/unicorn/ssl_configurator.rb +104 -0
- data/lib/unicorn/ssl_server.rb +42 -0
- data/lib/unicorn/stream_input.rb +149 -0
- data/lib/unicorn/tee_input.rb +126 -0
- data/lib/unicorn/tmpio.rb +29 -0
- data/lib/unicorn/util.rb +68 -0
- data/lib/unicorn/worker.rb +88 -0
- data/lib/unicorn.rb +107 -0
- data/local.mk.sample +59 -0
- data/man/man1/unicorn.1 +201 -0
- data/man/man1/unicorn_rails.1 +208 -0
- data/preplay_unicorn.gemspec +44 -0
- data/script/isolate_for_tests +50 -0
- data/setup.rb +1586 -0
- data/t/.gitignore +5 -0
- data/t/GNUmakefile +82 -0
- data/t/README +42 -0
- data/t/bin/content-md5-put +36 -0
- data/t/bin/sha1sum.rb +17 -0
- data/t/bin/unused_listen +40 -0
- data/t/bin/utee +12 -0
- data/t/broken-app.ru +12 -0
- data/t/detach.ru +11 -0
- data/t/env.ru +3 -0
- data/t/heartbeat-timeout.ru +12 -0
- data/t/my-tap-lib.sh +201 -0
- data/t/oob_gc.ru +21 -0
- data/t/oob_gc_path.ru +21 -0
- data/t/pid.ru +3 -0
- data/t/preread_input.ru +17 -0
- data/t/rack-input-tests.ru +21 -0
- data/t/rails3-app/.gitignore +4 -0
- data/t/rails3-app/Gemfile +26 -0
- data/t/rails3-app/Rakefile +10 -0
- data/t/rails3-app/app/controllers/application_controller.rb +4 -0
- data/t/rails3-app/app/helpers/application_helper.rb +2 -0
- data/t/rails3-app/app/views/layouts/application.html.erb +14 -0
- data/t/rails3-app/config/application.rb +46 -0
- data/t/rails3-app/config/boot.rb +6 -0
- data/t/rails3-app/config/database.yml +22 -0
- data/t/rails3-app/config/environment.rb +5 -0
- data/t/rails3-app/config/environments/development.rb +19 -0
- data/t/rails3-app/config/environments/production.rb +42 -0
- data/t/rails3-app/config/environments/test.rb +32 -0
- data/t/rails3-app/config/initializers/backtrace_silencers.rb +7 -0
- data/t/rails3-app/config/initializers/inflections.rb +10 -0
- data/t/rails3-app/config/initializers/mime_types.rb +5 -0
- data/t/rails3-app/config/initializers/secret_token.rb +7 -0
- data/t/rails3-app/config/initializers/session_store.rb +8 -0
- data/t/rails3-app/config/locales/en.yml +5 -0
- data/t/rails3-app/config/routes.rb +58 -0
- data/t/rails3-app/config.ru +4 -0
- data/t/rails3-app/db/seeds.rb +7 -0
- data/t/rails3-app/doc/README_FOR_APP +2 -0
- data/t/rails3-app/lib/tasks/.gitkeep +0 -0
- data/t/rails3-app/public/404.html +1 -0
- data/t/rails3-app/public/500.html +1 -0
- data/t/rails3-app/public/x.txt +1 -0
- data/t/rails3-app/script/rails +9 -0
- data/t/rails3-app/test/performance/browsing_test.rb +9 -0
- data/t/rails3-app/test/test_helper.rb +13 -0
- data/t/rails3-app/vendor/plugins/.gitkeep +0 -0
- data/t/sslgen.sh +71 -0
- data/t/t0000-http-basic.sh +50 -0
- data/t/t0001-reload-bad-config.sh +53 -0
- data/t/t0002-config-conflict.sh +49 -0
- data/t/t0002-parser-error.sh +94 -0
- data/t/t0003-working_directory.sh +51 -0
- data/t/t0004-heartbeat-timeout.sh +69 -0
- data/t/t0004-working_directory_broken.sh +24 -0
- data/t/t0005-working_directory_app.rb.sh +37 -0
- data/t/t0006-reopen-logs.sh +83 -0
- data/t/t0006.ru +13 -0
- data/t/t0007-working_directory_no_embed_cli.sh +44 -0
- data/t/t0008-back_out_of_upgrade.sh +110 -0
- data/t/t0009-broken-app.sh +56 -0
- data/t/t0009-winch_ttin.sh +59 -0
- data/t/t0010-reap-logging.sh +55 -0
- data/t/t0011-active-unix-socket.sh +79 -0
- data/t/t0012-reload-empty-config.sh +85 -0
- data/t/t0013-rewindable-input-false.sh +24 -0
- data/t/t0013.ru +12 -0
- data/t/t0014-rewindable-input-true.sh +24 -0
- data/t/t0014.ru +12 -0
- data/t/t0015-configurator-internals.sh +25 -0
- data/t/t0016-trust-x-forwarded-false.sh +30 -0
- data/t/t0017-trust-x-forwarded-true.sh +30 -0
- data/t/t0018-write-on-close.sh +23 -0
- data/t/t0019-max_header_len.sh +49 -0
- data/t/t0020-at_exit-handler.sh +49 -0
- data/t/t0021-process_detach.sh +29 -0
- data/t/t0100-rack-input-tests.sh +124 -0
- data/t/t0116-client_body_buffer_size.sh +80 -0
- data/t/t0116.ru +16 -0
- data/t/t0300-rails3-basic.sh +28 -0
- data/t/t0301-rails3-missing-config-ru.sh +33 -0
- data/t/t0302-rails3-alt-working_directory.sh +32 -0
- data/t/t0303-rails3-alt-working_directory_config.ru.sh +56 -0
- data/t/t0304-rails3-alt-working_directory_no_embed_cli.sh +52 -0
- data/t/t0600-https-server-basic.sh +48 -0
- data/t/t9000-preread-input.sh +48 -0
- data/t/t9001-oob_gc.sh +47 -0
- data/t/t9002-oob_gc-path.sh +75 -0
- data/t/test-lib.sh +113 -0
- data/t/test-rails3.sh +27 -0
- data/t/write-on-close.ru +11 -0
- data/test/aggregate.rb +15 -0
- data/test/benchmark/README +50 -0
- data/test/benchmark/dd.ru +18 -0
- data/test/benchmark/stack.ru +8 -0
- data/test/exec/README +5 -0
- data/test/exec/test_exec.rb +1055 -0
- data/test/rails/app-1.2.3/.gitignore +2 -0
- data/test/rails/app-1.2.3/Rakefile +7 -0
- data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
- data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-1.2.3/config/boot.rb +11 -0
- data/test/rails/app-1.2.3/config/database.yml +12 -0
- data/test/rails/app-1.2.3/config/environment.rb +13 -0
- data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
- data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
- data/test/rails/app-1.2.3/config/routes.rb +6 -0
- data/test/rails/app-1.2.3/db/.gitignore +0 -0
- data/test/rails/app-1.2.3/log/.gitignore +1 -0
- data/test/rails/app-1.2.3/public/404.html +1 -0
- data/test/rails/app-1.2.3/public/500.html +1 -0
- data/test/rails/app-2.0.2/.gitignore +2 -0
- data/test/rails/app-2.0.2/Rakefile +7 -0
- data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.0.2/config/boot.rb +11 -0
- data/test/rails/app-2.0.2/config/database.yml +12 -0
- data/test/rails/app-2.0.2/config/environment.rb +17 -0
- data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
- data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.0.2/config/routes.rb +6 -0
- data/test/rails/app-2.0.2/db/.gitignore +0 -0
- data/test/rails/app-2.0.2/log/.gitignore +1 -0
- data/test/rails/app-2.0.2/public/404.html +1 -0
- data/test/rails/app-2.0.2/public/500.html +1 -0
- data/test/rails/app-2.1.2/.gitignore +2 -0
- data/test/rails/app-2.1.2/Rakefile +7 -0
- data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.1.2/config/boot.rb +111 -0
- data/test/rails/app-2.1.2/config/database.yml +12 -0
- data/test/rails/app-2.1.2/config/environment.rb +17 -0
- data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
- data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.1.2/config/routes.rb +6 -0
- data/test/rails/app-2.1.2/db/.gitignore +0 -0
- data/test/rails/app-2.1.2/log/.gitignore +1 -0
- data/test/rails/app-2.1.2/public/404.html +1 -0
- data/test/rails/app-2.1.2/public/500.html +1 -0
- data/test/rails/app-2.2.2/.gitignore +2 -0
- data/test/rails/app-2.2.2/Rakefile +7 -0
- data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.2.2/config/boot.rb +111 -0
- data/test/rails/app-2.2.2/config/database.yml +12 -0
- data/test/rails/app-2.2.2/config/environment.rb +17 -0
- data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
- data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.2.2/config/routes.rb +6 -0
- data/test/rails/app-2.2.2/db/.gitignore +0 -0
- data/test/rails/app-2.2.2/log/.gitignore +1 -0
- data/test/rails/app-2.2.2/public/404.html +1 -0
- data/test/rails/app-2.2.2/public/500.html +1 -0
- data/test/rails/test_rails.rb +287 -0
- data/test/test_helper.rb +300 -0
- data/test/unit/test_configurator.rb +158 -0
- data/test/unit/test_droplet.rb +28 -0
- data/test/unit/test_http_parser.rb +860 -0
- data/test/unit/test_http_parser_ng.rb +716 -0
- data/test/unit/test_http_parser_xftrust.rb +38 -0
- data/test/unit/test_request.rb +197 -0
- data/test/unit/test_response.rb +99 -0
- data/test/unit/test_server.rb +289 -0
- data/test/unit/test_signals.rb +207 -0
- data/test/unit/test_sni_hostnames.rb +47 -0
- data/test/unit/test_socket_helper.rb +192 -0
- data/test/unit/test_stream_input.rb +204 -0
- data/test/unit/test_tee_input.rb +296 -0
- data/test/unit/test_upload.rb +306 -0
- data/test/unit/test_util.rb +100 -0
- metadata +428 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
# :enddoc:
|
3
|
+
# no stable API here
|
4
|
+
require 'unicorn_http'
|
5
|
+
|
6
|
+
# TODO: remove redundant names
|
7
|
+
Unicorn.const_set(:HttpRequest, Unicorn::HttpParser)
|
8
|
+
class Unicorn::HttpParser
|
9
|
+
|
10
|
+
# default parameters we merge into the request env for Rack handlers
|
11
|
+
DEFAULTS = {
|
12
|
+
"rack.errors" => $stderr,
|
13
|
+
"rack.multiprocess" => true,
|
14
|
+
"rack.multithread" => false,
|
15
|
+
"rack.run_once" => false,
|
16
|
+
"rack.version" => [1, 1],
|
17
|
+
"SCRIPT_NAME" => "",
|
18
|
+
|
19
|
+
# this is not in the Rack spec, but some apps may rely on it
|
20
|
+
"SERVER_SOFTWARE" => "Unicorn #{Unicorn::Const::UNICORN_VERSION}"
|
21
|
+
}
|
22
|
+
|
23
|
+
NULL_IO = StringIO.new("")
|
24
|
+
|
25
|
+
# :stopdoc:
|
26
|
+
# A frozen format for this is about 15% faster
|
27
|
+
REMOTE_ADDR = 'REMOTE_ADDR'.freeze
|
28
|
+
RACK_INPUT = 'rack.input'.freeze
|
29
|
+
@@input_class = Unicorn::TeeInput
|
30
|
+
|
31
|
+
def self.input_class
|
32
|
+
@@input_class
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.input_class=(klass)
|
36
|
+
@@input_class = klass
|
37
|
+
end
|
38
|
+
# :startdoc:
|
39
|
+
|
40
|
+
# Does the majority of the IO processing. It has been written in
|
41
|
+
# Ruby using about 8 different IO processing strategies.
|
42
|
+
#
|
43
|
+
# It is currently carefully constructed to make sure that it gets
|
44
|
+
# the best possible performance for the common case: GET requests
|
45
|
+
# that are fully complete after a single read(2)
|
46
|
+
#
|
47
|
+
# Anyone who thinks they can make it faster is more than welcome to
|
48
|
+
# take a crack at it.
|
49
|
+
#
|
50
|
+
# returns an environment hash suitable for Rack if successful
|
51
|
+
# This does minimal exception trapping and it is up to the caller
|
52
|
+
# to handle any socket errors (e.g. user aborted upload).
|
53
|
+
def read(socket)
|
54
|
+
clear
|
55
|
+
e = env
|
56
|
+
|
57
|
+
# From http://www.ietf.org/rfc/rfc3875:
|
58
|
+
# "Script authors should be aware that the REMOTE_ADDR and
|
59
|
+
# REMOTE_HOST meta-variables (see sections 4.1.8 and 4.1.9)
|
60
|
+
# may not identify the ultimate source of the request. They
|
61
|
+
# identify the client for the immediate request to the server;
|
62
|
+
# that client may be a proxy, gateway, or other intermediary
|
63
|
+
# acting on behalf of the actual source client."
|
64
|
+
e[REMOTE_ADDR] = socket.kgio_addr
|
65
|
+
|
66
|
+
# short circuit the common case with small GET requests first
|
67
|
+
socket.kgio_read!(16384, buf)
|
68
|
+
if parse.nil?
|
69
|
+
# Parser is not done, queue up more data to read and continue parsing
|
70
|
+
# an Exception thrown from the parser will throw us out of the loop
|
71
|
+
false until add_parse(socket.kgio_read!(16384))
|
72
|
+
end
|
73
|
+
e[RACK_INPUT] = 0 == content_length ?
|
74
|
+
NULL_IO : @@input_class.new(socket, self)
|
75
|
+
e.merge!(DEFAULTS)
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
# :enddoc:
|
3
|
+
# Writes a Rack response to your client using the HTTP/1.1 specification.
|
4
|
+
# You use it by simply doing:
|
5
|
+
#
|
6
|
+
# status, headers, body = rack_app.call(env)
|
7
|
+
# http_response_write(socket, status, headers, body)
|
8
|
+
#
|
9
|
+
# Most header correctness (including Content-Length and Content-Type)
|
10
|
+
# is the job of Rack, with the exception of the "Date" and "Status" header.
|
11
|
+
module Unicorn::HttpResponse
|
12
|
+
|
13
|
+
# Every standard HTTP code mapped to the appropriate message.
|
14
|
+
CODES = Rack::Utils::HTTP_STATUS_CODES.inject({}) { |hash,(code,msg)|
|
15
|
+
hash[code] = "#{code} #{msg}"
|
16
|
+
hash
|
17
|
+
}
|
18
|
+
CRLF = "\r\n"
|
19
|
+
|
20
|
+
# writes the rack_response to socket as an HTTP response
|
21
|
+
def http_response_write(socket, status, headers, body)
|
22
|
+
status = CODES[status.to_i] || status
|
23
|
+
|
24
|
+
if headers
|
25
|
+
buf = "HTTP/1.1 #{status}\r\n" \
|
26
|
+
"Date: #{httpdate}\r\n" \
|
27
|
+
"Status: #{status}\r\n" \
|
28
|
+
"Connection: close\r\n"
|
29
|
+
headers.each do |key, value|
|
30
|
+
next if %r{\A(?:Date\z|Connection\z)}i =~ key
|
31
|
+
if value =~ /\n/
|
32
|
+
# avoiding blank, key-only cookies with /\n+/
|
33
|
+
buf << value.split(/\n+/).map! { |v| "#{key}: #{v}\r\n" }.join
|
34
|
+
else
|
35
|
+
buf << "#{key}: #{value}\r\n"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
socket.write(buf << CRLF)
|
39
|
+
end
|
40
|
+
|
41
|
+
body.each { |chunk| socket.write(chunk) }
|
42
|
+
ensure
|
43
|
+
body.respond_to?(:close) and body.close
|
44
|
+
end
|
45
|
+
end
|