class Qwik::Response
Constants
- COOKIE_EXP
- MIME_TYPES
Attributes
basicauth[RW]
body[RW]
headers[R]
sessionid[RW]
status[RW]
Public Class Methods
new(config)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 27 def initialize(config) @config = config clear end
Public Instance Methods
[](k)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 65 def [](k) return @headers[k] end
[]=(k, v)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 69 def []=(k, v) @headers[k] = v end
clear()
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 37 def clear @body = nil @status = 200 @cookies = [] @headers = {} @mimetypes = {} @basicauth = nil @sessionid = nil end
get_mimetypes(ext)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 56 def get_mimetypes(ext) @mimetypes[ext.downcase] end
imitate_apache_header_order(h)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 124 def imitate_apache_header_order(h) def h.each h = {} super {|k, v| h[k] = v } pre_header = %w(date server) post_header = %w(etag last-modified location cache-control pragma keep-alive transfer-encoding content-encoding content-length connection content-type) ar = [] pre_header.each {|k| if h[k] ar << [k, h[k]] h.delete(k) end } postar = [] post_header.each {|k| if h[k] postar << [k, h[k]] h.delete(k) end } h.each {|k, v| ar << [k, v] } ar += postar ar.each {|k, v| yield(k, v) } end end
make_mimetypes(mimetypes)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 51 def make_mimetypes(mimetypes) @mimetypes = mimetypes @mimetypes.update(MIME_TYPES) end
set_content_type(ext)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 60 def set_content_type(ext) mtype = get_mimetypes(ext) # Get content type. @headers['Content-Type'] = mtype end
set_webrick(response)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 47 def set_webrick(response) make_mimetypes(response.config[:MimeTypes]) end
setback(response)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 116 def setback(response) response.body = setback_body(@body) response.status = @status @cookies.each {|c| response.cookies << c } @headers.each {|k, v| response[k] = v } #imitate_apache_header_order(response.header) end
setback_body(body)
click to toggle source
# File vendor/qwik/lib/qwik/response.rb, line 101 def setback_body(body) case body when Array # wabisabi return body.format_xml when File return body # do not convert when String return body when IO return body else return body.to_s end end