Permalink
Browse files

show how to pass along a hostname

  • Loading branch information...
kraih committed Feb 24, 2017
1 parent 08bbd11 commit a0cb00f131658e95073f62872a369ddb086c1f48
Showing with 11 additions and 5 deletions.
  1. +1 −1 lib/Mojolicious/Command/get.pm
  2. +10 −4 lib/Mojolicious/Guides/Cookbook.pod
@@ -140,7 +140,7 @@ Mojolicious::Command::get - Get command
mojo get mojolicious.org '*' attr id
mojo get mojolicious.org 'h1, h2, h3' 3 text
mojo get https://api.metacpan.org/v0/author/SRI /name
mojo get http+unix://%2Ftmp%2Fmyapp.sock/hello.html
mojo get -H 'Host: example.com' http+unix://%2Ftmp%2Fmyapp.sock/index.html
Options:
-C, --charset <charset> Charset of HTML/XML content, defaults
@@ -1394,12 +1394,16 @@ C<http+unix://> and C<ws+unix://> schemes, and pass along a percent encoded path
use Mojo::UserAgent;
use Mojo::IOLoop;
# GET request via UNIX domain socket "/tmp/myapp.sock"
# GET request via UNIX domain socket "/tmp/foo.sock"
my $ua = Mojo::UserAgent->new;
say $ua->get('http+unix://%2Ftmp%2Fmyapp.sock/index.html')->result->body;
say $ua->get('http+unix://%2Ftmp%2Ffoo.sock/index.html')->result->body;
# WebSocket connection via UNIX domain socket "/tmp/myapp.sock"
$ua->websocket('ws+unix://%2Ftmp%2Fmyapp.sock/echo' => sub {
# GET request with HOST header via UNIX domain socket "/tmp/bar.sock"
my $tx = $ua->get('http+unix://%2Ftmp%2Fbar.sock' => {Host => 'example.com'});
say $tx->result->body;
# WebSocket connection via UNIX domain socket "/tmp/baz.sock"
$ua->websocket('ws+unix://%2Ftmp%2Fbaz.sock/echo' => sub {
my ($ua, $tx) = @_;
say 'WebSocket handshake failed!' and return unless $tx->is_websocket;
@@ -1414,6 +1418,8 @@ C<http+unix://> and C<ws+unix://> schemes, and pass along a percent encoded path
});
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
You can set the C<Host> header manually to pass along a hostname.
=head2 Command line
Don't you hate checking huge HTML files from the command line? Thanks to the

0 comments on commit a0cb00f

Please sign in to comment.