From 289e9b844efef10e2cf2ce751c0cc3ab395a4bbd Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Fri, 12 Apr 2013 14:01:24 -0300 Subject: [PATCH] Fixed Content-Type retrieval for Python 3. --- httpie/downloads.py | 3 +++ httpie/models.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/httpie/downloads.py b/httpie/downloads.py index 219e5ea0..43a04921 100644 --- a/httpie/downloads.py +++ b/httpie/downloads.py @@ -116,6 +116,9 @@ def filename_from_url(url, content_type): else: ext = mimetypes.guess_extension(content_type) + if ext == '.htm': # Python 3 + ext = '.html' + if ext: fn += ext diff --git a/httpie/models.py b/httpie/models.py index aa2b69b7..e1f094fa 100644 --- a/httpie/models.py +++ b/httpie/models.py @@ -87,7 +87,13 @@ class HTTPMessage(object): @property def content_type(self): """Return the message content type.""" - ct = self._orig.headers.get('Content-Type', '') + ct = self._orig.headers.get( + b'Content-Type', + self._orig.headers.get( + 'Content-Type', + '' + ) + ) if isinstance(ct, bytes): ct = ct.decode() return ct