mirror of
https://github.com/httpie/cli.git
synced 2025-06-27 13:01:43 +02: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 (
|
from .streams import (
|
||||||
BaseStream, BufferedPrettyStream, EncodedStream, PrettyStream, RawStream,
|
BaseStream, BufferedPrettyStream, EncodedStream, PrettyStream, RawStream,
|
||||||
)
|
)
|
||||||
|
from ..utils import parse_content_type_header
|
||||||
|
|
||||||
|
|
||||||
MESSAGE_SEPARATOR = '\n\n'
|
MESSAGE_SEPARATOR = '\n\n'
|
||||||
@ -163,7 +164,10 @@ def get_stream_type_and_kwargs(
|
|||||||
if not is_stream and message_type is HTTPResponse:
|
if not is_stream and message_type is HTTPResponse:
|
||||||
# If this is a response, then check the headers for determining
|
# If this is a response, then check the headers for determining
|
||||||
# auto-streaming.
|
# 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:
|
if not env.stdout_isatty and not prettify_groups:
|
||||||
stream_class = RawStream
|
stream_class = RawStream
|
||||||
|
@ -124,6 +124,10 @@ def test_redirected_stream(httpbin):
|
|||||||
['Accept:text/event-stream'],
|
['Accept:text/event-stream'],
|
||||||
3
|
3
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
['Accept:text/event-stream; charset=utf-8'],
|
||||||
|
3
|
||||||
|
),
|
||||||
(
|
(
|
||||||
['Accept:text/plain'],
|
['Accept:text/plain'],
|
||||||
1
|
1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user