Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
335 stars 103 forks source link

[BUG] AsgiRequest hard codes scheme as 'https' in scope #1185

Closed jasonchester closed 4 months ago

jasonchester commented 1 year ago

Investigative information

Repro steps

Expected behavior

Scheme should either be http or https depending on the request being handled.

Actual behavior

Scheme is hard coded as https

Known workarounds

Contents of the requirements.txt file:

Related information

https://asgi.readthedocs.io/en/latest/specs/www.html

https://github.com/Azure/azure-functions-python-library/blob/cc3fd5d13770244bdcc1030be608c81d50df1ad2/azure/functions/_http_asgi.py#L32-L62

bhagyshricompany commented 1 year ago

Thanks for update will inform

bhagyshricompany commented 1 year ago

Issue needs mechanism to parse the scheme for incoming url. So will update on this once done.

jasonchester commented 1 year ago

@bhagyshricompany, WsgiRequest appears to handle scheme correctly with urllib.parse.urlparse

https://github.com/Azure/azure-functions-python-library/blob/cc3fd5d13770244bdcc1030be608c81d50df1ad2/azure/functions/_http_wsgi.py

#...
from urllib.parse import ParseResult, urlparse, unquote_to_bytes
#...
class WsgiRequest:
#...
    def __init__(self,
                 func_req: HttpRequest,
                 func_ctx: Optional[Context] = None):
        url: ParseResult = urlparse(func_req.url)
#...
        self.wsgi_url_scheme = url.scheme

#...
bhagyshricompany commented 1 year ago

@gavin-aguiar pls comment and update