#!/usr/bin/env perl
my
(
$method
,
$output_file
,
$header
,
$body
) = (
"GET"
,
"-"
,
""
);
my
$timeout
= 60;
GetOptions(
"method|X=s"
=> \
$method
,
"H=s"
, => \
$header
,
'd=s'
, => \
$body
,
"output|o=s"
=> \
$output_file
,
"timeout=s"
=> \
$timeout
,
);
$method
=
uc
(
$method
);
my
$uri_string
=
shift
(
@ARGV
) or
die
"$0 <url>"
;
my
$uri
= URI->new(
$uri_string
);
my
$res
= Hijk::request {
method
=>
$method
,
host
=>
$uri
->host,
port
=>
$uri
->port || 80,
timeout
=>
$timeout
*1000,
path
=>
$uri
->path,
query_string
=>
$uri
->query,
$header
? (
head
=> [
split
/: /,
$header
, 2] ) : (),
$body
? (
body
=>
$body
) : (),
};
print
$res
->{body};