1
0
mirror of https://github.com/httpie/cli.git synced 2026-06-20 11:32:56 +02:00

Automatically enable --stream on server sent events (#1226)

* Automatically enable --stream when used chunked encoding

* try fix 3.6 mock issue

* Only enable on text/event-stream

Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
This commit is contained in:
Batuhan Taskaya
2021-12-08 18:49:12 +03:00
committed by GitHub
parent 62e43abc86
commit 207b970d94
4 changed files with 55 additions and 2 deletions
+16
View File
@@ -36,6 +36,22 @@ def get_headers(handler):
handler.end_headers()
@TestHandler.handler('GET', '/drip')
def chunked_drip(handler):
handler.send_response(200)
accept = handler.headers.get('Accept')
if accept is not None:
handler.send_header('Content-Type', accept)
handler.send_header('Transfer-Encoding', 'chunked')
handler.end_headers()
for _ in range(3):
body = 'test\n'
handler.wfile.write(f'{len(body):X}\r\n{body}\r\n'.encode('utf-8'))
handler.wfile.write('0\r\n\r\n'.encode('utf-8'))
@pytest.fixture(scope="function")
def http_server():
"""A custom HTTP server implementation for our tests, that is