Index: [Article Count Order] [Thread]

Date: Wed, 22 May 2002 20:34:47 +0900
From: GOTO Kentaro <gotoken@notwork.org>
Subject: [webricken:97] Re: Full Request URL?
To: webricken@notwork.org
Message-Id: <200205221134.g4MBYlrF065627@miso.k.notwork.org>
In-Reply-To: <20020522104939.GA27266@peta.cs.auc.dk>
References: <20020522104939.GA27266@peta.cs.auc.dk>
X-Mail-Count: 00097

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