Class: NonCachingFileHandler

Inherits:
WEBrick::HTTPServlet::FileHandler
  • Object
show all
Defined in:
lib/tasks/test-task.rb

Instance Method Summary collapse

Instance Method Details

#do_GET(req, res) ⇒ Object



104
105
106
107
108
# File 'lib/tasks/test-task.rb', line 104

def do_GET(req, res)
  super
  set_default_content_type(res, req.path)
  prevent_caching(res)
end

#set_default_content_type(res, path) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/tasks/test-task.rb', line 110

def set_default_content_type(res, path)
  res['Content-Type'] = case path
    when /\.js$/ then 'text/javascript'
    when /\.html$/ then 'text/html'
    when /\.css$/ then 'text/css'
    else 'text/plain'
  end
end