From fee2a0361b4124dbd5565cee2a90ffb0c80ab7b0 Mon Sep 17 00:00:00 2001 From: Stephen Reay Date: Wed, 25 Sep 2019 14:26:50 +0700 Subject: [PATCH] Add `-H` option to allow http:// generated URLs. Fixes curl/h2c#8 --- h2c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/h2c b/h2c index aa6ae70..5230cfa 100755 --- a/h2c +++ b/h2c @@ -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", @@ -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")) { @@ -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; @@ -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) {