#!perl
use strict;
use warnings;
use Glib qw/TRUE FALSE/;
use Glib::Object::Introspection;

Glib::Object::Introspection->setup (
  basename => 'Soup',
  version => '2.4',
  package => 'HTTP::Soup');

my $session = HTTP::Soup::SessionAsync->new;
$session->add_feature_by_type ('HTTP::Soup::ContentDecoder');
$session->add_feature_by_type ('HTTP::Soup::CookieJar');
$session->set (user_agent => "get ",
               accept_language_auto => TRUE);

my $msg = HTTP::Soup::Message->new ('GET', 'http://google.com');

$session->send_message ($msg);

my $uri = $msg->get_uri;
my $path = $uri->to_string (TRUE);

printf "GET %s HTTP/1.%d\n",
       $path,
       $msg->get_http_version eq "http-1-1" ? 1 : 0;
my $headers = $msg->get ('request-headers');
$headers->foreach (sub { printf "%s: %s\n", shift, shift; }, undef);
print "\n";

printf "GET %s HTTP/1.%d %s\n",
       $path,
       $msg->get_http_version eq "http-1-1" ? 1 : 0,
       $msg->get ('reason-phrase');
$headers = $msg->get ('response-headers');
$headers->foreach (sub { printf "%s: %s\n", shift, shift; }, undef);
