develooper Front page | perl.libwww | Postings from August 2001

RE: set Host in Header

Thread Previous | Thread Next
From:
Rob Dixon
Date:
August 1, 2001 04:36
Subject:
RE: set Host in Header
Message ID:
CCEMJEKLAEJOBCELMGNIIENOCAAA.rob@dixon.nildram.co.uk
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:angela@team.outblaze.com]
> Sent: 01 August 2001 12:10
> To: libwww@perl.org
> 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
>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About