Angela
This is basically fine, but you've got mismatched quotes, you're using
$request_login when I think you mean $request, and you don't set the referer.
$request_login->header('Host' => host2.com');
should become
$request->referer ('http://host1.com/test');
$request->header ('Host' => 'host2.com');
and all will be well!
Cheers,
Rob
> -----Original Message-----
> From: Angela [mailto:[EMAIL PROTECTED]]
> Sent: 01 August 2001 12:10
> To: [EMAIL PROTECTED]
> Subject: set Host in Header
>
>
> Hi,
>
> I am using libwww-perl-5.53_94. I want to ask how to set the host in the
> header. I can do it with direct socket, but seems not work with LWP. Any
> idea? Thanks a lot.
>
> Angela.
>
> === LWP === not work
> my $ua = new LWP::UserAgent;
> my $request = new HTTP::Request('GET', 'http://host1.com/test?name=angela);
> $request_login->header('Host' => host2.com');
> my $response = $ua->request($request);
>
> === Socket === work
> my $address = sockaddr_in(80, inet_aton('http://host1.com'));
> with header like:
> POST /test HTTP/
> Referer: http://host1.com/test
> Host: host2.com
> ...
> name=angela
>