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

Handle default ports in WSGITransport #1469

Merged
merged 3 commits into from Feb 16, 2021
Merged

Handle default ports in WSGITransport #1469

merged 3 commits into from Feb 16, 2021

Conversation

abersheeran
Copy link
Member

@abersheeran abersheeran commented Feb 16, 2021

https://www.python.org/dev/peps/pep-3333/#environ-variables

SERVER_NAME, SERVER_PORT
------------------------------------------------------------
When HTTP_HOST is not set, these variables can be combined to determine a default. See the URL Reconstruction section below for more detail. SERVER_NAME and SERVER_PORT are required strings and must never be empty.

Fixed #1468

https://www.python.org/dev/peps/pep-3333/#environ-variables

> SERVER_NAME, SERVER_PORT
> When HTTP_HOST is not set, these variables can be combined to determine a default. See the URL Reconstruction section below for more detail. SERVER_NAME and SERVER_PORT are required strings and must never be empty.
@abersheeran abersheeran changed the title Fix #1468 environ["SERVER_PORT"] can't be "None" Feb 16, 2021
@abersheeran abersheeran changed the title environ["SERVER_PORT"] can't be "None" WSGI environ["SERVER_PORT"] can't be "None" Feb 16, 2021
Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Also, is there a unit test we could add in test_wsgi.py about this?

httpx/_transports/wsgi.py Outdated Show resolved Hide resolved
@florimondmanca florimondmanca added the bug Something isn't working label Feb 16, 2021
@florimondmanca
Copy link
Member

@abersheeran I went ahead and pushed some commits for the modifications to get this PR in shape, hope you don't mind.

Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this contribution!

We're not sure yet when 0.17.0 will be released (the team needs to circle back on that), but once merged this would at least be available for git installation.

@florimondmanca florimondmanca changed the title WSGI environ["SERVER_PORT"] can't be "None" Handle default ports in WSGITransport Feb 16, 2021
@florimondmanca florimondmanca merged commit 02a692a into encode:master Feb 16, 2021
@abersheeran
Copy link
Member Author

Thank you for your quick response~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

environ["SERVER_PORT"] can't be "None"
2 participants