Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

construct full url to pass to MockRequest#env_for #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/reel/rack/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ def route_request(request)
:input => request.body.to_s,
"REMOTE_ADDR" => request.remote_addr
}.merge(convert_headers(request.headers))

status, headers, body = app.call ::Rack::MockRequest.env_for(request.url, options)

# Construct full url so that rack can generate a correct environment.
# see https://github.com/rack/rack/blob/master/lib/rack/mock.rb.
url = "http://#{request.headers['Host']}#{request.url}"

status, headers, body = app.call ::Rack::MockRequest.env_for(url, options)

if body.respond_to?(:to_str)
request.respond status_symbol(status), headers, body.to_str
Expand Down