Skip to content

Commit fee2a03

Browse files
stephenreaybagder
authored andcommitted
Add -H option to allow http:// generated URLs.
Fixes #8
1 parent 79a3dec commit fee2a03

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

h2c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ sub usage {
77
" -a Allow curl's default headers\n",
88
" -d Output man page HTML links after command line\n",
99
" -h Show short help\n",
10+
" -H Output HTTP generated URLs instead\n",
1011
" -i Ignore HTTP version\n",
1112
" --libcurl Output libcurl code instead\n",
1213
" -n Output notes after command line\n",
@@ -28,6 +29,7 @@ my $disableheadersnotseen = 1;
2829
my $shellcompatible = 1; # may not been windows command prompt compat
2930
my $uselongoptions = 1; # instead of short
3031
my $uselibcurl = 0; # --libcurl
32+
my $usehttp = 0;
3133

3234
while($ARGV[0]) {
3335
if(($ARGV[0] eq "-h") || ($ARGV[0] eq "--help")) {
@@ -41,6 +43,10 @@ while($ARGV[0]) {
4143
$usedocs = 1;
4244
shift @ARGV;
4345
}
46+
elsif($ARGV[0] eq "-H") {
47+
$usehttp = 1;
48+
shift @ARGV;
49+
}
4450
elsif($ARGV[0] eq "-i") {
4551
$usesamehttpversion = 0;
4652
shift @ARGV;
@@ -370,10 +376,10 @@ foreach my $h (sort keys %header) {
370376
}
371377

372378
if($path =~ /[ &?]/) {
373-
$url = sprintf "\"https://%s%s\"", $header{'host'}, $path;
379+
$url = sprintf "\"%s://%s%s\"", $usehttp ? "http" : "https", $header{'host'}, $path;
374380
}
375381
else {
376-
$url = sprintf "https://%s%s", $header{'host'}, $path;
382+
$url = sprintf "%s://%s%s", $usehttp ? "http" : "https", $header{'host'}, $path;
377383
}
378384

379385
if($disabledheaders || $addedheaders) {

0 commit comments

Comments
 (0)