mirror of
https://github.com/httpie/cli.git
synced 2024-11-21 23:33:12 +01:00
Checking headers to determine auto-streaming (#1383)
This commit is contained in:
parent
5e76ebc5e1
commit
9f7612cdeb
@ -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
|
||||
|
@ -124,6 +124,10 @@ def test_redirected_stream(httpbin):
|
||||
['Accept:text/event-stream'],
|
||||
3
|
||||
),
|
||||
(
|
||||
['Accept:text/event-stream; charset=utf-8'],
|
||||
3
|
||||
),
|
||||
(
|
||||
['Accept:text/plain'],
|
||||
1
|
||||
|
Loading…
Reference in New Issue
Block a user