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