David,

Thanks for keeping us updated. 
I'm sure this will be useful to other readers facing a similar issue.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
 

-----Message d'origine-----
De : David Fogel [mailto:[email protected]] 
Envoyé : lundi 9 mars 2009 19:10
À : [email protected]
Objet : RE: VirtualHost can't match on port number

Hi Jerome, Thierry-

After spending some time in my debugger I've found my problem:

The main difference between my code and the Thierry's test code is that I
was setting host names on the virtual hosts (since this is how I needed to
deploy them).  In order to test this setup on my local machine, I use an
HTTP testing tool called "Http Client" ( http://ditchnet.org/httpclient/ ,
not to be confused with apache httpclient).  This tool allows you to
customize http requests and view the full response headers, etc).  It has a
feature that allows the user to add custom headers.  I was using this
feature to add custom "Host" headers, so that I could test the routing to my
different virtual hosts.

My error was that I didn't include the port number in the Host header value.

For example, I wrote:

    Host: a.site.com

instead of:

    Host: a.site.com:8888

I ommitted it because I already had the port specified in the address URI:

    http://localhost:8888/path/to/resource/

But according to the HTTP spec, the Host header field, if present (and if
the Request-URI is not an absolute URI), should provide the port number.

So, because I was omitting the port number from the Host field, the Restlet
Request did not contain a port number.  (Presumably because the internal
server assumes it will be there if the Host header is present).

When using Virtual Hosts without setting host names (as in Thierry's
example), this isn't an issue.  But it also appears that in the absence of a
Host header, that the internal server WILL have a port number in the
Request, which I assume it fills in by looking at the internal
ServerSocket/Connector port number.

Perhaps the internal server should use this socket port number as a fallback
(instead of the scheme default port number)?  

Anyhow, sorry for the false alarm, and thanks for looking in to it!

- Dave Fogel

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=12981
05

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1298730

Reply via email to