Skip to content

Commit

Permalink
appservice: Fix /new Content-Type
Browse files Browse the repository at this point in the history
Use web.json_response() helper to automatically send a correct
Content-Type.
  • Loading branch information
martinpitt committed Sep 20, 2022
1 parent b0fe7d4 commit 3158bee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion appservice/multiplexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def handle_session_new(self, request):
raise NotImplementedError('cannot create sessions other than podman')

if pod_status >= 200 and pod_status < 300:
response = web.Response(status=200, text=json.dumps({'id': sessionid}))
response = web.json_response({'id': sessionid})
await update_session(sessionid, 'wait_target')
else:
response = web.Response(status=pod_status, text=f'creating session container failed: {content}')
Expand Down
1 change: 1 addition & 0 deletions test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def request(self, url, retries=0):
def newSession(self):
response = self.request(f'{self.api_url}{config.ROUTE_API}/sessions/new')
self.assertEqual(response.status, 200)
self.assertEqual(response.getheader('Content-Type'), 'application/json; charset=utf-8')
sessionid = json.load(response)['id']
self.assertIsInstance(sessionid, str)

Expand Down

0 comments on commit 3158bee

Please sign in to comment.