Skip to content

Commit cf14aa4

Browse files
author
Marco Paolini
committed
Add debug log for CORS headers
1 parent 3a96572 commit cf14aa4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pushpull/websocket/client.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111

1212
async def challenge(url, name, fd_in, fd_out, loop=None):
1313
with aiohttp.ClientSession(loop=loop) as session:
14-
async with session.ws_connect('{}?name={}'.format(url, name)) as ws:
14+
async with session.ws_connect('{}?name={}'.format(url, name), headers={'Origin': 'localhost'}) as ws:
1515
logger.debug('opening websocket')
16+
if logger.isEnabledFor(logging.DEBUG):
17+
for header in ('Access-Control-Allow-Origin', 'Access-Control-Allow-Credentials',
18+
'Access-Control-Allow-Methods', 'Access-Control-Allow-Headers',
19+
'Access-Control-Expose-Headers'):
20+
logger.debug('CORS header {} origin: {!r}'.format(header, ws._response.headers.get(header)))
1621
sender = send_from_fd_to_ws(fd_in, ws, loop=loop)
1722
receiver = send_from_ws_to_fd(ws, fd_out)
1823
done, pending = await asyncio.wait([sender, receiver], return_when=asyncio.FIRST_COMPLETED)

0 commit comments

Comments
 (0)