You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2026-04-26 20:02:11 +02:00
Fix displaying of status code without a status message. (#1301)
Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
This commit is contained in:
@@ -18,14 +18,17 @@ class TestHandler(BaseHTTPRequestHandler):
|
||||
return func
|
||||
return inner
|
||||
|
||||
def do_GET(self):
|
||||
def do_generic(self):
|
||||
parse_result = urlparse(self.path)
|
||||
func = self.handlers['GET'].get(parse_result.path)
|
||||
func = self.handlers[self.command].get(parse_result.path)
|
||||
if func is None:
|
||||
return self.send_error(HTTPStatus.NOT_FOUND)
|
||||
|
||||
return func(self)
|
||||
|
||||
do_GET = do_generic
|
||||
do_POST = do_generic
|
||||
|
||||
|
||||
@TestHandler.handler('GET', '/headers')
|
||||
def get_headers(handler):
|
||||
@@ -73,6 +76,15 @@ def random_encoding(handler):
|
||||
handler.wfile.write('0\r\n\r\n'.encode('utf-8'))
|
||||
|
||||
|
||||
@TestHandler.handler('POST', '/status/msg')
|
||||
def status_custom_msg(handler):
|
||||
content_len = int(handler.headers.get('content-length', 0))
|
||||
post_body = handler.rfile.read(content_len).decode()
|
||||
|
||||
handler.send_response(200, post_body)
|
||||
handler.end_headers()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def http_server():
|
||||
"""A custom HTTP server implementation for our tests, that is
|
||||
|
||||
Reference in New Issue
Block a user