From e374eeea2912cec3c5bcf0b96740a3fa9725d6d0 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 25 Apr 2022 17:11:41 +0200 Subject: [PATCH] Backport PR #798: missing required arguments in utils.fetch --- jupyter_server/serverapp.py | 2 +- jupyter_server/utils.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index f2c337d404..8e448dc30c 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -504,7 +504,7 @@ def shutdown_server(server_info, timeout=5, log=None): if log: log.debug("POST request to %sapi/shutdown", url) - fetch(url, method="POST", headers={"Authorization": "token " + server_info["token"]}) + fetch(url, method="POST", body=b"", headers={"Authorization": "token " + server_info["token"]}) # Poll to see if it shut down. for _ in range(timeout * 10): if not check_pid(pid): diff --git a/jupyter_server/utils.py b/jupyter_server/utils.py index c7eb9a71f5..714bd9836c 100644 --- a/jupyter_server/utils.py +++ b/jupyter_server/utils.py @@ -346,7 +346,9 @@ def fetch(urlstring, method="GET", body=None, headers=None): Send a HTTP, HTTPS, or HTTP+UNIX request to a Tornado Web Server. Returns a tornado HTTPResponse. """ - with _request_for_tornado_client(urlstring) as request: + with _request_for_tornado_client( + urlstring, method=method, body=body, headers=headers + ) as request: response = HTTPClient(AsyncHTTPClient).fetch(request) return response @@ -356,7 +358,9 @@ async def async_fetch(urlstring, method="GET", body=None, headers=None, io_loop= Send an asynchronous HTTP, HTTPS, or HTTP+UNIX request to a Tornado Web Server. Returns a tornado HTTPResponse. """ - with _request_for_tornado_client(urlstring) as request: + with _request_for_tornado_client( + urlstring, method=method, body=body, headers=headers + ) as request: response = await AsyncHTTPClient(io_loop).fetch(request) return response