From 761c0a49e48fcf1ac6eb335693e0a2cea0a9e247 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Wed, 20 Jun 2007 06:16:56 +0000 Subject: [PATCH] Fixed #4549 -- WSGI server now sets mime type correctly for admin media content. Thanks, Stefane Fermgier git-svn-id: http://code.djangoproject.com/svn/django/trunk@5502 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 + django/core/servers/basehttp.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index e8e7be1a78..260fe511c7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -100,6 +100,7 @@ answer newbie questions, and generally made Django that much better: Marc Fargas favo@exoweb.net Bill Fenner + Stefane Fermgier Matthew Flanagan Eric Floehr Jorge Gajon diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py index 9e603b42d4..f3dc6915d2 100644 --- a/django/core/servers/basehttp.py +++ b/django/core/servers/basehttp.py @@ -9,7 +9,7 @@ been reviewed for security issues. Don't use it for production use. from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from types import ListType, StringType -import os, re, sys, time, urllib +import os, re, sys, time, urllib, mimetypes __version__ = "0.1" __all__ = ['WSGIServer','WSGIRequestHandler','demo_app'] @@ -629,6 +629,9 @@ class AdminMediaHandler(object): else: status = '200 OK' headers = {} + mime_type = mimetypes.guess_type(file_path)[0] + if mime_type: + headers['Content-Type'] = mime_type output = [fp.read()] fp.close() start_response(status, headers.items())