mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
Support more MIME types for common file types.
In `servlet-respond', the server defaults to Content-Type "text/html; charset=UTF-8" for extensions that don't appear in `mime-type-from-extension'. This meant that CSS files, JavaScript files, and various types of image files were getting the wrong Content-Type, which was fine when they were served directly, but caused clients to close the connection when they were loaded over HTTP/1.1, which can deliver back-to-back resources on the same connection. Sort the types in the `mime-type-from-extension' list now that it is longer. It's still not long enough for the order to be material for performance.
This commit is contained in:
parent
153b4d894a
commit
9b6099ca87
1 changed files with 16 additions and 6 deletions
|
@ -24,15 +24,25 @@
|
|||
;; most of these are plain text for easier viewing in the browser
|
||||
(define (mime-type-from-extension ext)
|
||||
(assq-ref
|
||||
'((htm . "text/html; charset=utf-8")
|
||||
'((c . "text/plain; charset=utf-8")
|
||||
(css . "text/css; charset=utf-8")
|
||||
(gif . "image/gif")
|
||||
(h . "text/plain; charset=utf-8")
|
||||
(htm . "text/html; charset=utf-8")
|
||||
(html . "text/html; charset=utf-8")
|
||||
(jpeg . "image/jpeg")
|
||||
(jpg . "image/jpeg")
|
||||
(js . "application/javascript; charset=utf-8")
|
||||
(json . "application/json; charset=utf-8")
|
||||
(md . "text/plain; charset=utf-8")
|
||||
(mp3 . "audio/mpeg")
|
||||
(org . "text/plain; charset=utf-8")
|
||||
(pdf . "application/pdf")
|
||||
(png . "image/png")
|
||||
(scm . "text/plain; charset=utf-8")
|
||||
(sld . "text/plain; charset=utf-8")
|
||||
(c . "text/plain; charset=utf-8")
|
||||
(h . "text/plain; charset=utf-8")
|
||||
(txt . "text/plain; charset=utf-8")
|
||||
(org . "text/plain; charset=utf-8")
|
||||
(md . "text/plain; charset=utf-8"))
|
||||
(svg . "image/svg+xml")
|
||||
(txt . "text/plain; charset=utf-8"))
|
||||
(and (string? ext) (string->symbol ext))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
Loading…
Add table
Reference in a new issue