Skip to content

Instantly share code, notes, and snippets.

@rhwlo
Last active Jan 13, 2019
Embed
What would you like to do?
example server and client to reproduce a Reason-Phrase bug in Python’s aiohttp library (https://github.com/aio-libs/aiohttp/issues/3532)
import asyncio
from urllib.parse import urljoin
from aiohttp.client import request
async def main():
for endpoint in ["/success_without_reason", "/failure_without_reason"]:
async with request("get", urljoin("http://0.0.0.0:8080",
endpoint)) as resp:
resp.raise_for_status()
print(f"{endpoint} passes ok")
asyncio.get_event_loop().run_until_complete(main())
from aiohttp import web
async def success_without_reason(request):
return web.Response(body="everything is ok", status=200, reason="")
async def failure_without_reason(request):
return web.Response(body="my tummy feels funny", status=500, reason="")
def init():
app = web.Application()
app.router.add_get("/success_without_reason", success_without_reason)
app.router.add_get("/failure_without_reason", failure_without_reason)
return app
web.run_app(init())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment