]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Perform cheaper comparison first
authorTom Christie <tom@tomchristie.com>
Wed, 27 Jun 2018 20:45:46 +0000 (21:45 +0100)
committerTom Christie <tom@tomchristie.com>
Wed, 27 Jun 2018 20:45:46 +0000 (21:45 +0100)
starlette/response.py

index e18a7fcc1479a720ac1529d8d5d39581ac6947ed..f831bcfeee96195a75f3d25368c55ceb5e5c324a 100644 (file)
@@ -48,7 +48,7 @@ class Response:
             self.headers["content-length"] = str(len(self.body))
 
     def set_content_type(self):
-        if "content-type" not in self.headers and self.media_type is not None:
+        if self.media_type is not None and "content-type" not in self.headers:
             content_type = self.media_type
             if content_type.startswith("text/") and self.charset is not None:
                 content_type += "; charset=%s" % self.charset