lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 9/7/05, Javier Guerra <> wrote:
> ok, i found it.  the only use is to set the CGILua 'SERVER_PORT' variable.

Just to ponder the specs a bit more, the CGI/1.1 (draft 3) spec states
(as you have pointed out):
6.1.16. SERVER_PORT 

The SERVER_PORT metavariable is set to the port on which the request
was received, as used in the <port> part of the Script-URI.
3.2. The Script-URI


The various components of the Script-URI are defined by some of the
metavariables (see section 4 below);

    script-uri = protocol "://" SERVER_NAME ":" SERVER_PORT enc-script
                 enc-path-info "?" QUERY_STRING
6.1.16. SERVER_PORT  (continued)

If the <port> portion of the script-URI is blank, the actual port
number upon which the request was received MUST be supplied.

Servers MUST provide this metavariable to scripts.

So, if I'm reading all this right, Xavante is correctly setting the
CGI SERVER_PORT variable to the parsed <port> from the URI, _OR_
defaulting to the running server's listening port if their is no
explicit port in the URI. (I get this from "If the <port> portion of
the script-URI is blank, the actual port number upon which the request
was received MUST be supplied." -- note the word "MUST".)

> According to the standard CGI protocol: "The port number to which the request
> was sent." seems to agree with you.

Yes, for the formal CGI SERVER_PORT variable.

> but now i think Xavante shouldn't set any default, that should be done in the
> the GCILuaHandler set.api() function

As for the default port from the httpd request, RFC2616, the HTTP/1.1
spec, states:
3.2.2 http URL

   The "http" scheme is used to locate network resources via the HTTP
   protocol. This section defines the scheme-specific syntax and
   semantics for http URLs.

   http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]

   If the port is empty or not given, port 80 is assumed.

Note "port  80 is assumed".  This strongly suggests that the default
value for the port parsed from the httpd request should be 80.

> any comments?

Summation of my understanding of the defaults:
  - httpd request port: 80
  - GGI SERVER_PORT: running server's listening port

I suppose the canonical approach would be to study all the established
httpd servers (apache, etc) and see how their httpd request parsers
and CGI handlers deal with this.  But I also suppose that neither you
nor I have the time to do this.  Don't you love specifications?

All of this appears to confirm the subtle, but sometimes very
significant difference, between the parsed port from the httpd
request, and the CGI SERVER_PORT value.  The difference really shows
up, for example, when firewall port redirections come into play. 
Sometimes a web application needs to know both.