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

Add method to reconstruct the request URI from a WSGI environment. #13

Closed
amcgregor opened this issue Jun 22, 2020 · 2 comments
Closed

Comments

@amcgregor
Copy link
Member

No description provided.

@amcgregor
Copy link
Member Author

amcgregor commented Mar 11, 2021

Initial commit, above, adds the factory method URI.from_wsgi which may be passed a WSGI environment dictionary or dictionary-alike, or any object which has an environ attribute that is a WSGI environment dictionary, such as a WebOb Request instance. Tests forthcoming (having a mild issue with it emitting the default port number for the given protocol) but in-progress.

pytest current test failure
    def test_wsgi_unpacking():
        webob = pytest.importorskip('webob')
    
        url = 'https://example.com/foo/bar?baz=27'
    
        request = webob.Request.blank(url)
        uri = URI.from_wsgi(request)
    
>       assert str(uri) == url
E    AssertionError: assert 'https://exam...oo/bar?baz=27' == 'https://exam...oo/bar?baz=27'
E      - https://example.com/foo/bar?baz=27
E      + https://example.com:443/foo/bar?baz=27
E      ?                    ++++

request    = <Request at 0x108fd1100 GET https://example.com/foo/bar?baz=27>
uri        = URI('https://example.com:443/foo/bar?baz=27')
url        = 'https://example.com/foo/bar?baz=27'
webob      = <module 'webob' from '/Users/amcgregor/Projects/marrow/.venv/lib/python3.8/site-packages/webob/__init__.py'>

@amcgregor
Copy link
Member Author

amcgregor commented Mar 11, 2021

Sub-optimally corrected by inclusion of the two likely culprits in a WSGI environment (http and https) in a port mapping dictionary uri.uri:SERVICES; this should be loaded from /etc/services or such a file should be bundled with the library, ref: #15. (System-provided eliminates maintenance overhead for this file.)

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

No branches or pull requests

1 participant