You've already forked httpie-cli
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user