summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Egleston <github@kamash.com>2022-05-06 00:59:22 -0600
committerGitHub <noreply@github.com>2022-05-06 09:59:22 +0300
commit9f7612cdeb560730651bf223ae3f2dc866c3c3f3 (patch)
tree6b82357be939029880181ebb9982d341b2707e33
parent5e76ebc5e14032fab8fef186efb4872fe108ecf3 (diff)
Checking headers to determine auto-streaming (#1383)
-rw-r--r--httpie/output/writer.py6
-rw-r--r--tests/test_stream.py4
2 files changed, 9 insertions, 1 deletions
diff --git a/httpie/output/writer.py b/httpie/output/writer.py
index c580e22c..4a2949bc 100644
--- a/httpie/output/writer.py
+++ b/httpie/output/writer.py
@@ -17,6 +17,7 @@ from .processing import Conversion, Formatting
from .streams import (
BaseStream, BufferedPrettyStream, EncodedStream, PrettyStream, RawStream,
)
+from ..utils import parse_content_type_header
MESSAGE_SEPARATOR = '\n\n'
@@ -163,7 +164,10 @@ def get_stream_type_and_kwargs(
if not is_stream and message_type is HTTPResponse:
# If this is a response, then check the headers for determining
# auto-streaming.
- is_stream = headers.get('Content-Type') == 'text/event-stream'
+ raw_content_type_header = headers.get('Content-Type', None)
+ if raw_content_type_header:
+ content_type_header, _ = parse_content_type_header(raw_content_type_header)
+ is_stream = (content_type_header == 'text/event-stream')
if not env.stdout_isatty and not prettify_groups:
stream_class = RawStream
diff --git a/tests/test_stream.py b/tests/test_stream.py
index a8950d29..45b8e4dd 100644
--- a/tests/test_stream.py
+++ b/tests/test_stream.py
@@ -125,6 +125,10 @@ def test_redirected_stream(httpbin):
3
),
(
+ ['Accept:text/event-stream; charset=utf-8'],
+ 3
+ ),
+ (
['Accept:text/plain'],
1
)