ASGI and RSGI headers format #15
-
Trying to Test ASGI + Falcon with this code: import falcon.asgi
from granian import Granian
class Home:
async def on_get(self, req, resp):
resp.status = falcon.HTTP_200 # This is the default status
resp.content_type = falcon.MEDIA_TEXT # Default is JSON, so override
resp.text = "Hello, World!"
async def on_post(self, req, resp):
raw_data = await req.stream.read()
print("data", raw_data)
resp.status = falcon.HTTP_200 # This is the default status
resp.content_type = falcon.MEDIA_TEXT # Default is JSON, so override
resp.text = raw_data
app = falcon.asgi.App()
home = Home()
app.add_route("/", home)
if __name__ == "__main__":
Granian(
f"falcon-asgi:app",
address="0.0.0.0",
port=4001,
workers= 1, #multiprocessing.cpu_count(),
backlog=2048,
interface="asgi",
websockets=False
).serve() I got the error File "/usr/local/lib/python3.10/dist-packages/falcon/asgi/request.py", line 393, in __init__
for header_name, header_value in scope['headers']:
ValueError: too many values to unpack (expected 2) The headers for ASGI are incompatible, in uvicorn they are an array of tuples, and in the ASGI docs: For HTTP:
https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope For WebSockets:
https://asgi.readthedocs.io/en/latest/specs/www.html#websocket-connection-scope |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@cirospaciari this is a bug now tracked in #16 |
Beta Was this translation helpful? Give feedback.
@cirospaciari this is a bug now tracked in #16