module Qeweney::ResponseMethods

def respond_with_static_file(path, etag, last_modified, opts)

def respond_with_static_file(path, etag, last_modified, opts)
  cache_headers = {
    'etag' => etag,
    'last-modified' => last_modified,
  }
  File.open(path, 'r') do |f|
    if opts[:headers]
      opts[:headers].merge!(cache_headers)
    else
      opts[:headers] = cache_headers
    end
    # accept_encoding should return encodings in client's order of preference
    accept_encoding.each do |encoding|
      case encoding
      when 'deflate'
        return serve_io_deflate(f, opts)
      when 'gzip'
        return serve_io_gzip(f, opts)
      end
    end
    serve_io(f, opts)
  end
end