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 wsgi environment building #573

Merged
merged 3 commits into from
Oct 21, 2015

Conversation

redixin
Copy link
Contributor

@redixin redixin commented Oct 17, 2015

Fixed issues:

SERVER_NAME and SERVER_PORT variables may be determined in two ways:

if protocol is HTTP/1.0:
Value of Host header. If there is no such header, then address of
transport may be taken (transport.get_extra_info('sockname'))

if protocol is HTTP/1.1:
Value of Host header. If there is no such header, the Bad Request
should be raised, because this header is required in HTTP/1.1.

REMOTE_ADDR and REMOTE_PORT should be address and port of host connected
to http server.

https://www.ietf.org/rfc/rfc3875:
4.1.8.  REMOTE_ADDR
   The REMOTE_ADDR variable MUST be set to the network address of the
   client sending the request to the server.

Also, header Authorization should not be in environment at all.

Fixed issues:

SERVER_NAME and SERVER_PORT variables may be determined in two ways:

 if protocol is HTTP/1.0:
  Value of `Host` header. If there is no such header, then address of
  transport may be taken (transport.get_extra_info('sockname'))

 if protocol is HTTP/1.1:
  Value of `Host` header. If there is no such header, the Bad Request
  should be raised, because this header is required in HTTP/1.1.

REMOTE_ADDR and REMOTE_PORT should be address and port of host connected
to http server. (https://www.ietf.org/rfc/rfc3875)

Also, header `Authorization` should not be in environment at all.
'GET', '/', (1, 0), headers, True, 'deflate')
environ = self._make_one()
self.assertEqual('1.2.3.4', environ["SERVER_NAME"])
self.assertEqual('8080', environ["SERVER_PORT"])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm probably I should also check self.transport.get_extra_info called with proper arguments...

@asvetlov
Copy link
Member

@redixin please add a message next time after pushing an update for PR.
The reason is: github did not send a notification email on pushes, only on new comments.
I rely on these emails to track PR activities.

@@ -63,16 +63,11 @@ def create_wsgi_environ(self, message, payload):
'SERVER_PROTOCOL': 'HTTP/%s.%s' % message.version
}

# authors should be aware that REMOTE_HOST and REMOTE_ADDR
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the comment worth to be saved?
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Added this comment on lines 86-90

According to CGI 1.1 server port should be set to the TCP/IP port
number on which this request is received from the client.

Also add comment about REMOTE_HOST, REMOTE_ADDR and SERVER_PORT.

Also added new and removed some redundant tests.
@redixin
Copy link
Contributor Author

redixin commented Oct 20, 2015

New patch added

    Fix SERVER_PORT in wsgi headers

    According to CGI 1.1 server port should be set to the TCP/IP port
    number on which this request is received from the client.

    Also add comment about REMOTE_HOST, REMOTE_ADDR and SERVER_PORT.

    Also added new and removed some redundant tests.

asvetlov added a commit that referenced this pull request Oct 21, 2015
@asvetlov asvetlov merged commit b8ce8fb into aio-libs:master Oct 21, 2015
@asvetlov
Copy link
Member

Perfect!
Thanks a lot!

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants