Skip to content

Commit 434e888

Browse files
committed
Fix RequestHandler unit tests
1 parent 17700c5 commit 434e888

File tree

3 files changed

+8
-414
lines changed

3 files changed

+8
-414
lines changed

lib/phusion_passenger/request_handler.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def initialize(owner_pipe, options = {})
112112
"analytics_logger",
113113
"pool_account_username"
114114
)
115+
@thread_handler = options["thread_handler"] || ThreadHandler
115116
@concurrency = 1
116117
@memory_limit = options["memory_limit"] || 0
117118
if options["pool_account_password_base64"]
@@ -415,16 +416,18 @@ def start_threads
415416
:server_socket => @http_socket,
416417
:socket_name => "HTTP socket",
417418
:protocol => :http,
418-
:app_group_name => @app_group_name
419+
:app_group_name => @app_group_name,
420+
:connect_password => @connect_password
419421
}
420422

423+
thread_handler = @thread_handler
421424
@threads_mutex.synchronize do
422425
@concurrency.times do |i|
423426
thread = Thread.new(i) do |number|
424427
Thread.current.abort_on_exception = true
425428
begin
426429
Thread.current[:name] = "Worker #{number + 1}"
427-
handler = ThreadHandler.new(self, main_socket_options)
430+
handler = thread_handler.new(self, main_socket_options)
428431
handler.install
429432
handler.main_loop
430433
ensure
@@ -438,7 +441,7 @@ def start_threads
438441
Thread.current.abort_on_exception = true
439442
begin
440443
Thread.current[:name] = "HTTP helper worker"
441-
handler = ThreadHandler.new(self, http_socket_options)
444+
handler = thread_handler.new(self, http_socket_options)
442445
handler.install
443446
handler.main_loop
444447
ensure

lib/phusion_passenger/request_handler/thread_handler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def parse_http_request(connection, channel, buffer)
197197

198198
data = ""
199199
while data !~ /\r\n\r\n/ && data.size < MAX_HEADER_SIZE
200-
data << socket.readpartial(16 * 1024)
200+
data << connection.readpartial(16 * 1024)
201201
end
202202
if data.size >= MAX_HEADER_SIZE
203203
warn("*** Passenger RequestHandler warning: " <<
@@ -220,7 +220,7 @@ def parse_http_request(connection, channel, buffer)
220220
headers["SCRIPT_NAME"] = ""
221221
headers["PATH_INFO"] = path_info
222222
headers["SERVER_NAME"] = "127.0.0.1"
223-
headers["SERVER_PORT"] = socket.addr[1].to_s
223+
headers["SERVER_PORT"] = connection.addr[1].to_s
224224
headers["SERVER_PROTOCOL"] = protocol
225225
else
226226
header, value = line.split(/\s*:\s*/, 2)

0 commit comments

Comments
 (0)