Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in ASGI middleware if the ASGI client is None #296

Merged
merged 2 commits into from
Sep 27, 2021

Conversation

imjoehaines
Copy link
Member

@imjoehaines imjoehaines commented Sep 23, 2021

Goal

Our ASGI middleware assumes that the client in the ASGI scope cannot be None, but this isn't the case:

client (Iterable[Unicode string, int]) – A two-item iterable of [host, port], where host is the remote host’s IPv4 or IPv6 address, and port is the remote port as an integer. Optional; if missing defaults to None.
https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope

This PR adds a guard to avoid an error if there is a client but it is None

See #295

Testing

Added a unit test that runs an ASGI app with the client set to None. This fails in master but passes in this branch

I also manually tested with Uvicorn on a unix socket (#295 (comment))

@imjoehaines imjoehaines merged commit 6b0f2df into next Sep 27, 2021
@imjoehaines imjoehaines deleted the fix-none-client branch September 27, 2021 09:25
@imjoehaines imjoehaines mentioned this pull request Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants