class HttpStub::Server::Stub::Response::FileBody
Constants
- DEFAULT_HEADERS
Attributes
uri[R]
Public Class Methods
new(hash)
click to toggle source
# File lib/http_stub/server/stub/response/file_body.rb, line 14 def initialize(hash) @path = hash.dig(:file, :path) @uri = "file://#{@path}" end
Public Instance Methods
headers()
click to toggle source
# File lib/http_stub/server/stub/response/file_body.rb, line 19 def headers DEFAULT_HEADERS end
serve(application, response)
click to toggle source
# File lib/http_stub/server/stub/response/file_body.rb, line 23 def serve(application, response) application.send_file(@path, send_options(response)) end
to_s()
click to toggle source
# File lib/http_stub/server/stub/response/file_body.rb, line 27 def to_s @uri end
Private Instance Methods
send_options(response)
click to toggle source
# File lib/http_stub/server/stub/response/file_body.rb, line 33 def send_options(response) headers = response.headers { type: headers["content-type"] }.tap do |options| options[:last_modified] = headers["last-modified"] if headers["last-modified"] options[:disposition] = headers["content-disposition"] if headers["content-disposition"] end end