----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Tomcat Developers List" <[EMAIL PROTECTED]>
Sent: Wednesday, August 28, 2002 7:12 PM
Subject: Re: Spec question: RE BUG 12052


> On Wed, 28 Aug 2002, Bill Barker wrote:
>
> > > I think the decision to use the Host header is right, but
> > > I agree that it violates the wording in the servlet spec.
> > >
> > > The SERVER_PORT and the port in the Host: header are different
> > > beasts - in most use cases I've seen the user is interested
> > > in the second.
> >
> > Not anymore. ;-)  In the current 2.4 spec draft it is required to be
taken
> > from the Host header.
>
> I hope this is listed in the 'incompatible changes between 2.3 and 2.4'
:-)

Nope.
<spec-quote version="2.4" section="S.1">
Clarification of SERVER_NAME and SERVER_PORT in getServerName()
and getServerPort() (14.2.16)
</spec-quote>

>
> As for the new wording - am I missing the ':-)' ?

Here's mine :-)

>
> So: getServerPort() should return the same as the CGI variable SERVER_PORT
> ( which returns the server port, not the host header ! ), meaning the
> value of the part after : in the Host header.
>
> I didn't know that the servlet spec can define new meanings for the
> CGI spec.
>

FWIW, I agree that the 2.4 servlet-spec and the CGI-spec are out of sync
here.  If I actually thought that any members of the JCP were subscribed to
this list, I'd think to ask for clarification before 2.4 went final. :)

> Costin
>
>
> > <spec-quote version="2.4" section="14.2.16">
> > getServerName()
> > public java.lang.String getServerName()
> > Returns the host name of the server to which the request was sent. For
HTTP
> > servlets, same as the value of the CGI variable SERVER_NAME, meaning the
> > value of the part before ":" in the Host header, if any, or the resolved
> > server
> > name, or the server IP address.
> > Returns: a String containing the name of the server
> >
> > getServerPort()
> > public int getServerPort()
> > Returns the port number to which the request was sent. For HTTP
servlets,
> > same as the value of the CGI variable SERVER_PORT, meaning the value of
the
> > part after ":" in the Host header, if any, or the server port where the
> > client
> > connection was accepted on.
> > Returns: an integer specifying the port number
> > </spec-quote>
> >
> > >
> > > Note that a load balancer or proxy is required ( AFAIK ) to insert
> > > Host: headers if none is present.
> > >
> > > Costin
> > >
> > > On 29 Aug 2002, Bojan Smojver wrote:
> > >
> > > > On Thu, 2002-08-29 at 04:28, Bill Barker wrote:
> > > >
> > > > > The question in 12052 is whether Apache should use the socket port
(as
> > it
> > > > > does now), or the port in the Host header.  When this came up with
the
> > > > > Coyote/Http11 connector, the decision was that the Host header was
the
> > > > > correct one.  I'd have to say that the bug is valid.
> > > >
> > > > This is what the API (2.2) docs say about the getServerPort():
> > > >
> > > > ----------------
> > > > Returns the port number on which this request was received. For HTTP
> > > > servlets, same as the value of the CGI variable SERVER_PORT.
> > > > ----------------
> > > >
> > > > This in itself could be contradicting, but I think that in the case
of
> > > > Apache it is pretty straightforward.
> > > >
> > > > This is what Apache 2.0 does to populate the variable SERVER_PORT:
> > > >
> > > > ----------------
> > > > apr_table_addn(e, "SERVER_PORT",
> > > >                   apr_psprintf(r->pool, "%u",
ap_get_server_port(r)));
> > > > ----------------
> > > >
> > > > And this is the ap_get_server_port():
> > > >
> > > > ----------------
> > > > AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r)
> > > > {
> > > >     apr_port_t port;
> > > >     core_dir_config *d =
> > > >       (core_dir_config *)ap_get_module_config(r->per_dir_config,
> > > > &core_module);
> > > >
> > > >     if (d->use_canonical_name == USE_CANONICAL_NAME_OFF
> > > >         || d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
> > > >
> > > >         /* With UseCanonicalName off Apache will form
self-referential
> > > >          * URLs using the hostname and port supplied by the client
if
> > > >          * any are supplied (otherwise it will use the canonical
name).
> > > >          */
> > > >         port = r->parsed_uri.port ? r->parsed_uri.port :
> > > >                r->server->port ? r->server->port :
> > > >                ap_default_port(r);
> > > >     }
> > > >     else { /* d->use_canonical_name == USE_CANONICAL_NAME_ON */
> > > >
> > > >         /* With UseCanonicalName on (and in all versions prior to
1.3)
> > > >          * Apache will use the hostname and port specified in the
> > > >          * ServerName directive to construct a canonical name for
the
> > > >          * server. (If no port was specified in the ServerName
> > > >          * directive, Apache uses the port supplied by the client if
> > > >          * any is supplied, and finally the default port for the
> > > > protocol
> > > >          * used.
> > > >          */
> > > >         port = r->server->port ? r->server->port :
> > > >                r->connection->local_addr->port ?
> > > > r->connection->local_addr->port
> > > >                ap_default_port(r);
> > > >     }
> > > >
> > > >     /* default */
> > > >     return port;
> > > > }
> > > > ----------------
> > > >
> > > > This doesn't seem like coming from headers, but rather from URL or
as
> > > > indicated by the server itself. What do you think?
> > > >
> > > > Bojan
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > >
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to