Skip to content

Commit 9d88001

Browse files
author
Achille Roussel
committed
allow scheme-less URLs
1 parent 699457d commit 9d88001

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

curl.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,14 @@ func run(ctx context.Context) error {
115115
return fmt.Errorf("too many arguments passed in the command line invocation of kubectl curl [URL] [container]")
116116
}
117117

118+
if strings.Index(query, "://") < 0 {
119+
query = "http://" + query
120+
}
121+
118122
requestURL, err := url.Parse(query)
119123
if err != nil {
120124
return fmt.Errorf("malformed URL: %w", err)
121125
}
122-
switch requestURL.Scheme {
123-
case "http", "https":
124-
case "":
125-
return fmt.Errorf("missing scheme in query URL: %s", query)
126-
default:
127-
return fmt.Errorf("unsupposed scheme in query URL: %s", query)
128-
}
129126

130127
podName, podPort, err := net.SplitHostPort(requestURL.Host)
131128
if err != nil {

curl/curl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,8 @@ func NewOptionSet() OptionSet {
10241024
ServiceName(""),
10251025
ShowError(false),
10261026
Silent(false),
1027-
//SOCKS4(""),
1028-
//SOCKS4a(""),
1027+
SOCKS4(""),
1028+
SOCKS4a(""),
10291029
SOCKS5Basic(false),
10301030
SOCKS5GssAPIService(""),
10311031
SOCKS5GssAPI(false),

0 commit comments

Comments
 (0)