in reply to Direct a LWP connection to a different host

if your only concern is LWP, then you can do this on a per UA basis using proxy settings...

use LWP::UserAgent; my $u = LWP::UserAgent->new; $u->proxy("http","http://www.apache.org/" +); print $u->get("http://google.com/")->as_string;

UPDATE: your milage may vary based on the HTTP Server you connect to, see followup replies for details

Replies are listed 'Best First'.
Re^2: Direct a LWP connection to a different host
by Aristotle (Chancellor) on Jan 31, 2005 at 07:40 UTC

    How can that work? HTTP requests sent to proxies differ from those sent to destination hosts.

    Makeshifts last the longest.

      This should work too, at least somewhat, because the main difference between the proxy request and the real request is that the GET request is changed from a relative to an absolute URL:

      Host: www.google.com GET http://www.google.com/

      instead of

      Host: www.google.com GET /

      But yes, that somewhat invalidates the intent to just redirect the socket connection and leave everything else as-is, to fake a different name resolution as there actually is.

        Yes, and I expected servers would return a 5XX response in such cases, It seems that instead, those I tried this with treat a request of this form as a request for the server root. So in a roundabout way it accidentally works as intended for (some of) the uses discussed in the root node. Strange.

        Makeshifts last the longest.