From 1f2aa328536480bd7b489871587e1621d805430d Mon Sep 17 00:00:00 2001 From: Harsh Thakkar Date: Thu, 24 Sep 2026 00:33:50 +0530 Subject: [PATCH] Treat event-stream media type case-insensitively Media types are case-insensitive per RFC 2045 section 5.1, but the auto-streaming check for Server-Sent Events compared the parsed Content-Type header literally, so a server responding with e.g. 'Text/Event-Stream' silently fell back to buffered output. --- httpie/output/writer.py | 2 +- tests/test_stream.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/httpie/output/writer.py b/httpie/output/writer.py index 4a2949bce2..136f0abac7 100644 --- a/httpie/output/writer.py +++ b/httpie/output/writer.py @@ -167,7 +167,7 @@ def get_stream_type_and_kwargs( 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') + is_stream = (content_type_header.lower() == '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 b0b9b8bde8..d9647fca96 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -128,6 +128,10 @@ def test_redirected_stream(httpbin): ['Accept:text/event-stream; charset=utf-8'], 3 ), + ( + ['Accept:Text/Event-Stream'], + 3 + ), ( ['Accept:text/plain'], 1