Index: [Article Count Order] [Thread]

Date: Thu, 23 May 2002 14:27:34 +0200
From: Lars Christensen <larsch@cs.auc.dk>
Subject: [webricken:102] Re: Full Request URL?
To: webricken@notwork.org
Message-Id: <20020523122734.GA25268@peta.cs.auc.dk>
In-Reply-To: <200205231130.g4NBUtrF068371@miso.k.notwork.org>
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>
X-Mail-Count: 00102

On Thu, May 23, 2002 at 08:30:54PM +0900, GOTO Kentaro wrote:> At Thu, 23 May 2002 12:12:18 +0200,> Lars Christensen wrote:> > >   s.mount_proc("/"){|req, res|> > >     res.body = "http://#{req['host']}#{req.request_uri}";> > >   }> > > Thanks. This helped in the case of HTTP/1.1. However, in the case of HT=TP/1.0> > (or others) it could be useful to have access to the return value of> > Socket#addr of the local.  This following patch adds this to the httpre=quest> > class.> > 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#locala=ddris garaunteed to do. I.e. using Socket#addr, it merely gets the ip, port orpossibly domain from the reverse lookup of the IP.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 thenames of the host. On a virtual host, the client would supply the 'Host' header, which should =theninstead be used as in my example. I suppose this is true, also for HTTP/1.0= (?)> 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 diffe=rentactions depending on which interface the request is made on, you would need= theSocket#addr information. The alternative, to start a server on each of theinterfaces seems to me a bit of overkill in, at least, my situtation.-- Lars Christensen
attatchment (application/pgp-signature) ignored