JustPaste.it

1 use 5.010;
2 use strict;
3 use warnings;
4 use DDP;
5
6 use Mojo::UserAgent;
7 use Mojo::Headers;
8 use Data::Dumper;
9
10 my $ua = Mojo::UserAgent->new();
11
12 #my $tx = $ua->build_tx(GET => 'http://localhost:3000/ololo');
13 my $tx = $ua->build_tx(GET => 'http://vk.com');
14 my %headers = (ยท
15 'Connection' => 'keep-alive',
16 'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/29.0.1547.65 Chrome/29.0.1547.65 Safari/537.36',
17 'Accept-Encoding' => 'gzip,deflate,sdch',
18 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
19 'Accept-Language' => 'en-US,en;q=0.8',
20 'Host' => 'localhost:3000'
21 );
22 $tx->req->headers->remove($_) for keys $tx->req->headers->to_hash;
23 $tx->req->headers->from_hash(\%headers);
24
25 say Dumper $tx;
26 p $tx->req->headers;
27
28 $ua->start($tx => sub {
29 my ($ua, $tx) = @_;
30 say 9999999999999999999;
31 say Dumper \@_;
32 #I expect to see vk.com response here .... ((
33 Mojo::IOLoop->stop;
34 });
35 Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
36