Skip to content

Instantly share code, notes, and snippets.

@quininer
Created August 1, 2015 09:40
Show Gist options
  • Save quininer/5f77ef4f6d4ca8b3ce82 to your computer and use it in GitHub Desktop.
Save quininer/5f77ef4f6d4ca8b3ce82 to your computer and use it in GitHub Desktop.
aiohttp wsgi PATH_INFO parse Error.
#!/usr/bin/env python
# encoding: utf-8
import asyncio
from http.client import responses
from aiohttp.wsgi import WSGIServerHttpProtocol
@asyncio.coroutine
def foo(env, start_res):
start_res(
"{} {}".format(200, responses.get(200)),
{}.items()
)
return [env.get('PATH_INFO').encode()]
loop = asyncio.get_event_loop()
loop.run_until_complete(
loop.create_server(
lambda: WSGIServerHttpProtocol(foo),
"127.0.0.1",
8000
)
)
loop.run_forever()
@quininer
Copy link
Author

quininer commented Aug 1, 2015

In [65]: get('http://127.0.0.1:8000//a').text
Out[65]: ''

In [66]: get('http://127.0.0.1:8000///a').text
Out[66]: '/a'

It is not reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment