Skip to content

Commit 5a9e91b

Browse files
committed
Use wsgi.url_scheme to determine secure connections
As a WSGI application, Webware 3 should check wsgi.url_scheme instead of the HTTPS environment variable in order to reliably detect secure connections. Note that mod_wsgi even removes the HTTPS environment variable.
1 parent d625bf3 commit 5a9e91b

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

webware/HTTPRequest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def protocol(self):
152152

153153
def isSecure(self):
154154
"""Check whether this is a HTTPS connection."""
155-
return self._environ.get('HTTPS', '').lower() == 'on'
155+
return self._environ.get('wsgi.url_scheme') == 'https'
156156

157157
# endregion Security
158158

webware/HTTPResponse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def recordSession(self):
404404
return
405405
cookie = Cookie(app.sessionName(trans), identifier)
406406
cookie.setPath(app.sessionCookiePath(trans))
407-
if trans.request().isSecure():
407+
if request.isSecure():
408408
cookie.setSecure(app.setting('SecureSessionCookie'))
409409
self.addCookie(cookie)
410410
if debug:

webware/Testing/TestIMS.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def writeContent(self):
3333
d = self.request().serverDictionary()
3434
self._host = d['HTTP_HOST'] # includes the port
3535
self._httpConnection = (
36-
http.client.HTTPSConnection
37-
if d.get('HTTPS', '').lower() == 'on'
36+
http.client.HTTPSConnection if d.get('wsgi.url_scheme') == 'https'
3837
else http.client.HTTPConnection)
3938
servletPath = self.request().servletPath()
4039
# pick a static file which is served up by Webware's UnknownFileHandler

0 commit comments

Comments
 (0)