abersheeran / a2wsgi

Convert WSGI app to ASGI app or ASGI app to WSGI app.
Apache License 2.0
226 stars 20 forks source link

feat: pass client's IP address and port to ASGI app via scope 'client' #6

Closed sralloza closed 4 years ago

sralloza commented 4 years ago

This PR will enable the ASGI application to access the client's IP address and the client's port by the tuple (client_ip, client_port) in scope["client"].

Note: needs testing.

Closes #5

abersheeran commented 4 years ago

https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope

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.

sralloza commented 4 years ago

What if REMOTE_ADDR is present but REMOTE_PORT isn't? Or vice versa?