From jonas at lophus.org Mon Jan 2 15:59:33 2012 From: jonas at lophus.org (Jonas H.) Date: Mon, 02 Jan 2012 15:59:33 +0100 Subject: [Web-SIG] SERVER_PORT and Unix sockets Message-ID: <4F01C655.7080609@lophus.org> Hello everyone! What is SERVER_PORT supposed to be set to if the WSGI server is only bound to a Unix socket? Some major Web servers (Gunicorn, CherryPy) set it to the empty string. Intuitively I'd rather not set it at all. What do you guys recommend? btw, www.wsgi.org != wsgi.org. That's very confusing. Jonas From rsyring at gmail.com Mon Jan 2 16:09:52 2012 From: rsyring at gmail.com (Randy Syring) Date: Mon, 02 Jan 2012 10:09:52 -0500 Subject: [Web-SIG] SERVER_PORT and Unix sockets In-Reply-To: <4F01C655.7080609@lophus.org> References: <4F01C655.7080609@lophus.org> Message-ID: <4F01C8C0.7010708@gmail.com> I'm sure you've read this: http://www.python.org/dev/peps/pep-0333/#environ-variables The following variables must be present, unless their value would be an empty string, in which case they may be omitted, except as otherwise noted below. <...snip...> SERVER_NAME, SERVER_PORT When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL. Note, however, that HTTP_HOST, if present, should be used in preference to SERVER_NAME for reconstructing the request URL. See the URL Reconstruction section below for more detail. SERVER_NAME and SERVER_PORT *can never be empty strings, and so are always required.* So, it sounds to me like the spec doesn't take unix sockets into consideration, which makes sense. Either way, if you omit, or set the value to an empty string, you are going to be violating the spec. FWIW, if it was me, I'd follow suit with what the other servers are doing. ------------------------------------- Randy Syring Intelicom |Level 12 Direct: 502-276-0459 Office: 502-212-9913 For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord (Rom 6:23) On 01/02/2012 09:59 AM, Jonas H. wrote: > Hello everyone! > > What is SERVER_PORT supposed to be set to if the WSGI server is only > bound to a Unix socket? > > Some major Web servers (Gunicorn, CherryPy) set it to the empty > string. Intuitively I'd rather not set it at all. > > What do you guys recommend? > > btw, www.wsgi.org != wsgi.org. That's very confusing. > > Jonas > _______________________________________________ > Web-SIG mailing list > Web-SIG at python.org > Web SIG: http://www.python.org/sigs/web-sig > Unsubscribe: > http://mail.python.org/mailman/options/web-sig/rsyring%40gmail.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chrism at plope.com Tue Jan 3 11:52:36 2012 From: chrism at plope.com (Chris McDonough) Date: Tue, 03 Jan 2012 05:52:36 -0500 Subject: [Web-SIG] PEP3333 and PATH_INFO Message-ID: <1325587956.5647.102.camel@thinko> Perrenial topic, it seems, from the archives. As far as I can tell from PEP 3333, every WSGI application that wants to run on both Python 2 and Python 3 and which uses PATH_INFO will need to define a helper function something like this: """ import sys def decode_path_info(environ, encoding='utf-8'): PY3 = sys.version_info[0] == 3 path_info = environ['PATH_INFO'] if PY3: return path_info.encode('latin-1').decode(encoding) else: return path_info.decode(encoding) """ Is there a more elegant way to handle this? - C