Index: [Article Count Order] [Thread]

Date: Sat, 25 May 2002 16:47:10 +0900
From: GOTO Kentaro <gotoken@notwork.org>
Subject: [webricken:104] Re: Full Request URL?
To: webricken@notwork.org
Message-Id: <200205250747.g4P7lArF075573@miso.k.notwork.org>
In-Reply-To: <20020523122734.GA25268@peta.cs.auc.dk>
References: <20020522104939.GA27266@peta.cs.auc.dk>	<200205221134.g4MBYlrF065627@miso.k.notwork.org>	<20020523101218.GA22193@peta.cs.auc.dk>	<200205231130.g4NBUtrF068371@miso.k.notwork.org>	<20020523122734.GA25268@peta.cs.auc.dk>
X-Mail-Count: 00104

At Thu, 23 May 2002 14:27:34 +0200,
Lars Christensen wrote:

> [1  <text/plain; us-ascii (quoted-printable)>]
> On Thu, May 23, 2002 at 08:30:54PM +0900, GOTO Kentaro wrote:
> > Thank you for patch.  However, I'm sorry to say that looks having
> > problem because Socket#addr uses gethostname(2) simply.  Generally
> > speaking, gethostname may differ from DNS record or /etc/hosts in the
> > LAN.  So Socket#addr is not appropriate for the host part of URL.
> > 
> > I looked for a platform independent way to get host name automatically
> > too, but there seems not existing.
> 
> To me, this seems more like the problem of defining what HTTPRequest#localaddr
> is garaunteed to do. I.e. using Socket#addr, it merely gets the ip, port or
> possibly domain from the reverse lookup of the IP.

I agreed.  Although Socket#addr fits conditioally to generate the URL,
it is natural to provide Socket#addr as an API of HTTPRequest.  For
example, that may be useful for log in multi A or AAAA RR environment
or mutli/aliased interface sutuations you mentioned below. 

> In case of non-virtual host, using this should work in a subsequent request,
> unless the server's DNS records and /etc/hosts files are disagreeing on the
> names of the host. 
> 
> On a virtual host, the client would supply the 'Host' header, which should then
> instead be used as in my example. I suppose this is true, also for HTTP/1.0 (?)
Yes, most agents would send Host header also for HTTP/1.0.  

# OT: But some old servers ignore Host header in HTTP/1.0 request,
# however, that is not a wrong action.  RFC 2145 gives the meaning of
# HTTP version number.

> > Then, I think default host part should be given manually by config or
> > something else.
> 
> If you want to run the webrick server on multiple interfaces and take different
> actions depending on which interface the request is made on, you would need the
> Socket#addr information. The alternative, to start a server on each of the
> interfaces seems to me a bit of overkill in, at least, my situtation.

Another option is stating servers with explicit :BindAddress. 
 localhost = HTTPServer.new(:BindAddress => "localhost", ...)
 lan       = HTTPServer.new(:BindAddress => addr1, ...)
 internet  = HTTPServer.new(:BindAddress => addr2, ...)

Anyway, I've got to think of adding an API to give local address
infomation ;)  What do you think, Yuzo?

What name is better?  localaddr, addr or something else?

-- Gotoken