Index: [Article Count Order] [Thread]

Date: Thu, 23 May 2002 22:20:13 +1200
From: Holden Glova <dsafari@xtra.co.nz>
Subject: [webricken:99] Re: Full Request URL?
To: webricken@notwork.org
Message-Id: <20020523102325.RJLC10730.mta2-rme.xtra.co.nz@there>
In-Reply-To: <200205221134.g4MBYlrF065627@miso.k.notwork.org>
References: <20020522104939.GA27266@peta.cs.auc.dk> <200205221134.g4MBYlrF065627@miso.k.notwork.org>
X-Mail-Count: 00099

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 22 May 2002 23:34, GOTO Kentaro wrote:
> At Wed, 22 May 2002 12:49:39 +0200,
>
> Lars Christensen wrote:
> > Is there a way to get the full URL of the requested document / resource?
> > My server has multiple domain names, and i'd like the full URL with the
> > hostname that the client requested the resource on.
>
> HOST request header includes that information in HTTP/1.1.
> Try access to http://your.domain:2002/foo/bar?baz=quux
>
>   require 'webrick'
>
>   s = WEBrick::HTTPServer.new(:Port => 2002)
>   s.mount_proc("/"){|req, res|
>     res.body = "http://#{req['host']}#{req.request_uri}";
>   }
>   s.start
>
> -- Gotoken

Interesting I was using req.path to get a similar value, which is preferred 
and why?

Remember that if you want to use just the string representation of the URI 
make sure to do a req.request_uri.to_str and do not use req.request_uri.to_s 
because it yields a different result.

- -- 
Signed,
Holden Glova
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE87MJd+mF116Lw2cQRArflAJ4yQFKZdNOJw7tJhBrHK8VZfcd9egCfbrCI
aq0iRYPI65jzhD85xtgxszo=
=67/G
-----END PGP SIGNATURE-----