Module: Httpserver::Mime

Included in:
WebServer
Defined in:
lib/httpserver/mime.rb

Instance Method Summary collapse

Instance Method Details

#get_content_type(path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/httpserver/mime.rb', line 3

def get_content_type(path)
  ext = File.extname(path)
  return "text/html"  if ext == ".html" or ext == ".htm"
  return "text/plain" if ext == ".txt"
  return "text/css"   if ext == ".css"
  return "image/jpeg" if ext == ".jpeg" or ext == ".jpg"
  return "image/gif"  if ext == ".gif"
  return "image/png"  if ext == ".png"
  return "image/bmp"  if ext == ".bmp"
  return "text/plain" if ext == ".rb"
  return "text/xml"   if ext == ".xml"
  return "text/xml"   if ext == ".xsl"
  return "text/html"
end