Skip to content

Commit

Permalink
add -i option to get command
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 23, 2016
1 parent 0d17841 commit 604d478
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

7.08 2016-09-23
- Added -i option to get command.
- Improved accuracy of finished_ok test in Test::Mojo.
- Fixed state transition bug in Mojo::Transaction::HTTP that caused message
bodies to be included in responses to HEAD requests.
Expand Down
1 change: 1 addition & 0 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -621,6 +621,7 @@ EXPERIMENTAL and might change without warning!
},
sub {
my ($subprocess, $err, @results) = @_;
say "Subprocess error: $err" and return if $err;
say "I $results[0] $results[1]!";
}
);
Expand Down
1 change: 1 addition & 0 deletions lib/Mojo/IOLoop/Subprocess.pm
Expand Up @@ -70,6 +70,7 @@ Mojo::IOLoop::Subprocess - Subprocesses
},
sub {
my ($subprocess, $err, @results) = @_;
say "Subprocess error: $err" and return if $err;
say "I $results[0] $results[1]!";
}
);
Expand Down
48 changes: 27 additions & 21 deletions lib/Mojolicious/Command/get.pm
Expand Up @@ -17,12 +17,13 @@ sub run {
my ($self, @args) = @_;

GetOptionsFromArray \@args,
'C|charset=s' => \my $charset,
'c|content=s' => \(my $content = ''),
'H|header=s' => \my @headers,
'M|method=s' => \(my $method = 'GET'),
'r|redirect' => \my $redirect,
'v|verbose' => \my $verbose;
'C|charset=s' => \my $charset,
'c|content=s' => \(my $content = ''),
'H|header=s' => \my @headers,
'i|inactivity-timeout=i' => \my $inactivity,
'M|method=s' => \(my $method = 'GET'),
'r|redirect' => \my $redirect,
'v|verbose' => \my $verbose;

@args = map { decode 'UTF-8', $_ } @args;
die $self->usage unless my $url = shift @args;
Expand All @@ -36,6 +37,8 @@ sub run {
$url !~ m!^/! ? $ua->proxy->detect : $ua->server->app($self->app);
$ua->max_redirects(10) if $redirect;

$ua->inactivity_timeout($inactivity) if defined $inactivity;

my $buffer = '';
$ua->on(
start => sub {
Expand Down Expand Up @@ -131,7 +134,7 @@ Mojolicious::Command::get - Get command
./myapp.pl get -H 'Accept: text/html' /hello.html 'head > title' text
./myapp.pl get //sri:secr3t@/secrets.json /1/content
mojo get mojolicious.org
mojo get -v -r google.com
mojo get -v -r -i 50 google.com
mojo get -v -H 'Host: mojolicious.org' -H 'Accept: */*' mojolicious.org
mojo get -M POST -H 'Content-Type: text/trololo' -c 'trololo' perl.org
mojo get mojolicious.org 'head > title' text
Expand All @@ -142,20 +145,23 @@ Mojolicious::Command::get - Get command
mojo get https://api.metacpan.org/v0/author/SRI /name
Options:
-C, --charset <charset> Charset of HTML/XML content, defaults to
auto-detection
-c, --content <content> Content to send with request
-H, --header <name:value> Additional HTTP header
-h, --help Show this summary of available options
--home <path> Path to home directory of your application,
defaults to the value of MOJO_HOME or
auto-detection
-M, --method <method> HTTP method to use, defaults to "GET"
-m, --mode <name> Operating mode for your application, defaults to
the value of MOJO_MODE/PLACK_ENV or
"development"
-r, --redirect Follow up to 10 redirects
-v, --verbose Print request and response headers to STDERR
-C, --charset <charset> Charset of HTML/XML content, defaults
to auto-detection
-c, --content <content> Content to send with request
-H, --header <name:value> Additional HTTP header
-h, --help Show this summary of available options
--home <path> Path to home directory of your
application, defaults to the value of
MOJO_HOME or auto-detection
-i, --inactivity-timeout <seconds> Inactivity timeout, defaults to the
value of MOJO_INACTIVITY_TIMEOUT or 20
-M, --method <method> HTTP method to use, defaults to "GET"
-m, --mode <name> Operating mode for your application,
defaults to the value of
MOJO_MODE/PLACK_ENV or "development"
-r, --redirect Follow up to 10 redirects
-v, --verbose Print request and response headers to
STDERR
=head1 DESCRIPTION
Expand Down

0 comments on commit 604d478

Please sign in to comment.