-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
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"]) |
There was a problem hiding this comment.
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...
@redixin please add a message next time after pushing an update for PR. |
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
New patch added
|
Fix wsgi environment building
Perfect! |
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 oftransport 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 Requestshould 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.
Also, header
Authorization
should not be in environment at all.