Replies: 3 comments 1 reply
-
Looks like it could be a tricky one. If you can write a complete test as a PR, that would be really helpful, then we can merge the test and figure out a way to fix the problem. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
1 reply
-
I messed with pytest without success, even with existing tests I've some error like However I wrote a full script: from aiohttp import web
import aiohttp
import ssl
import asyncio
import os
import signal
import sys
async def client():
# wait server
await asyncio.sleep(3)
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_verify_locations('client.pem')
async with aiohttp.ClientSession() as session:
async with session.get('https://127.0.0.1:8200', ssl_context=ssl_context) as resp:
await resp.content.read(1)
async def server():
async def handle_get(request):
return web.FileResponse('newfile')
# dummy file
f = open('newfile',"wb")
f.seek(64*1024*1024)
f.write(b"\0")
f.close()
app = web.Application()
app.add_routes([web.get('', handle_get)])
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain('server.pem', 'server.key')
loop = asyncio.get_event_loop()
loop.create_task(client())
# set up the web server
runner = web.AppRunner(app)
await runner.setup()
await web.TCPSite(runner, ssl_context=ssl_context, port=8200).start()
# wait forever, running both the web server and the tasks
await asyncio.Event().wait()
def signal_handler(signal, frame):
os.remove("newfile")
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
asyncio.get_event_loop().run_until_complete(server()) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I wrote a simple test server for my embedded device, which receive POST data and serve update firmware with GET.
However I always get following exception, I think it's because my device only read the firmware header for version comparison then close the connection. If I use curl GET to read the whole file then no exception is raised.
Is there anyway to suppress this exception ?
Beta Was this translation helpful? Give feedback.
All reactions