SERVER_PORT and Unix sockets

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SERVER_PORT and Unix sockets

Jonas Haag-2
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
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/lists%2B1324538118791-2206077%40n6.nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: SERVER_PORT and Unix sockets

Randy Syring-2
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
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/rsyring%40gmail.com


_______________________________________________
Web-SIG mailing list
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/lists%2B1324538118791-2206077%40n6.nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: SERVER_PORT and Unix sockets

Benoit Chesneau-3
In reply to this post by Jonas Haag-2
On Mon, Jan 2, 2012 at 3:59 PM, Jonas H. <[hidden email]> 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

Mmm are you sure it's empty in gunicorn?

For the server addres we are using socket.getsockname() for the
default so at this step the port can be null, but then  Host header
(HTTP_HOST) which override the defaults.  We are following the spec on
that's matter. So I'm surprised that port can be empty. Can you
provide an example I could reproduce?

- benoit
_______________________________________________
Web-SIG mailing list
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/lists%2B1324538118791-2206077%40n6.nabble.com