Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.
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
15 changes: 12 additions & 3 deletions lib/prax/public_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ def exists?
File.exists?(file_path) and !File.directory?(file_path)
end

def file_data
if Rack::RELEASE < "2.0.0"
file = Rack::File.new(nil)
file.path = file_path
file.serving(request.to_env)
else
file = Rack::File.new(file_path)
file.serving(Rack::Request.new(request.to_env), file_path)
end
end

def stream_to(io)
file = Rack::File.new(nil)
file.path = file_path
code, headers, body = file.serving(request.to_env)
code, headers, body = file_data

headers["Connection"] = "close"

Expand Down