Skip to content

Commit

Permalink
Add -H option to allow http:// generated URLs.
Browse files Browse the repository at this point in the history
Fixes #8
  • Loading branch information
stephenreay authored and bagder committed Oct 5, 2019
1 parent 79a3dec commit fee2a03
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions h2c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ sub usage {
" -a Allow curl's default headers\n",
" -d Output man page HTML links after command line\n",
" -h Show short help\n",
" -H Output HTTP generated URLs instead\n",
" -i Ignore HTTP version\n",
" --libcurl Output libcurl code instead\n",
" -n Output notes after command line\n",
Expand All @@ -28,6 +29,7 @@ my $disableheadersnotseen = 1;
my $shellcompatible = 1; # may not been windows command prompt compat
my $uselongoptions = 1; # instead of short
my $uselibcurl = 0; # --libcurl
my $usehttp = 0;

while($ARGV[0]) {
if(($ARGV[0] eq "-h") || ($ARGV[0] eq "--help")) {
Expand All @@ -41,6 +43,10 @@ while($ARGV[0]) {
$usedocs = 1;
shift @ARGV;
}
elsif($ARGV[0] eq "-H") {
$usehttp = 1;
shift @ARGV;
}
elsif($ARGV[0] eq "-i") {
$usesamehttpversion = 0;
shift @ARGV;
Expand Down Expand Up @@ -370,10 +376,10 @@ foreach my $h (sort keys %header) {
}

if($path =~ /[ &?]/) {
$url = sprintf "\"https://%s%s\"", $header{'host'}, $path;
$url = sprintf "\"%s://%s%s\"", $usehttp ? "http" : "https", $header{'host'}, $path;
}
else {
$url = sprintf "https://%s%s", $header{'host'}, $path;
$url = sprintf "%s://%s%s", $usehttp ? "http" : "https", $header{'host'}, $path;
}

if($disabledheaders || $addedheaders) {
Expand Down

0 comments on commit fee2a03

Please sign in to comment.