Skip to content

Commit

Permalink
Merge pull request #471 from faucct/patch-1
Browse files Browse the repository at this point in the history
Correct 'Content-Type' headers
  • Loading branch information
blink1073 authored Apr 9, 2021
2 parents 723786e + 588b5be commit 1f313d9
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions jupyter_server/gateway/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,13 @@ def load_connection_args(self, **kwargs):
if len(self._static_args) == 0:
self.init_static_args()

kwargs.update(self._static_args)
for arg, static_value in self._static_args.items():
if arg == 'headers':
given_value = kwargs.setdefault(arg, {})
if isinstance(given_value, dict):
given_value.update(static_value)
else:
kwargs[arg] = static_value
return kwargs


Expand Down Expand Up @@ -396,7 +402,9 @@ async def start_kernel(self, kernel_id=None, path=None, **kwargs):

json_body = json_encode({'name': kernel_name, 'env': kernel_env})

response = await gateway_request(kernel_url, method='POST', body=json_body)
response = await gateway_request(
kernel_url, method='POST', headers={'Content-Type': 'application/json'}, body=json_body
)
kernel = json_decode(response.body)
kernel_id = kernel['id']
self.log.info(f"Kernel started: {kernel_id}")
Expand Down Expand Up @@ -489,7 +497,9 @@ async def restart_kernel(self, kernel_id, now=False, **kwargs):
"""
kernel_url = self._get_kernel_endpoint_url(kernel_id) + '/restart'
self.log.debug(f"Request restart kernel at: {kernel_url}")
response = await gateway_request(kernel_url, method='POST', body=json_encode({}))
response = await gateway_request(
kernel_url, method='POST', headers={'Content-Type': 'application/json'}, body=json_encode({})
)
self.log.debug(f"Restart kernel response: {response.code} {response.reason}")

async def interrupt_kernel(self, kernel_id, **kwargs):
Expand All @@ -502,7 +512,9 @@ async def interrupt_kernel(self, kernel_id, **kwargs):
"""
kernel_url = self._get_kernel_endpoint_url(kernel_id) + '/interrupt'
self.log.debug(f"Request interrupt kernel at: {kernel_url}")
response = await gateway_request(kernel_url, method='POST', body=json_encode({}))
response = await gateway_request(
kernel_url, method='POST', headers={'Content-Type': 'application/json'}, body=json_encode({})
)
self.log.debug(f"Interrupt kernel response: {response.code} {response.reason}")

def shutdown_all(self, now=False):
Expand Down

0 comments on commit 1f313d9

Please sign in to comment.