***** infoCopter.com/perl *****

send-cookie-from-client



[ up ]

Example (http)

#!/usr/bin/perl -w
use strict;

use LWP::UserAgent;
use HTTP::Request::Common;
require HTTP::Headers;

&main();

sub main() {
	my $ua = LWP::UserAgent->new(agent => 'Bugzilla 4.711 ;-)');

	my %tags = ();
	$tags{'action'} = 'my action value';
	$tags{'id'    } = 'my id value äöü';

	my $h = HTTP::Headers->new(Date => 'Thu, 03 Feb 1994 00:00:00 GMT');
	   $h->push_header(Cookie => 'foo=foobar; path=/; expires=Sun, 27-Sep-2037');
	   $h->push_header(Cookie => 'bar=barfoo; path=/; expires=Sun, 27-Sep-2037');

	my $r = HTTP::Request->new(
		POST => 'http://www.example.com/cgi-bin/foo.pl', $h
	);

	$r->content("foo=foobar&bar=barfoo");

	print $r->as_string, "\n------------------------------\n";

	my $resp = $ua->request($r);

	print $resp->error_as_HTML unless $resp->is_success;
	print $resp->content();
}
© reto :)