File tree 1 file changed +12
-6
lines changed 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -2931,11 +2931,17 @@ func (pc *persistConn) closeLocked(err error) {
2931
2931
pc .mutateHeaderFunc = nil
2932
2932
}
2933
2933
2934
- var portMap = map [string ]string {
2935
- "http" : "80" ,
2936
- "https" : "443" ,
2937
- "socks5" : "1080" ,
2938
- "socks5h" : "1080" ,
2934
+ func schemePort (scheme string ) string {
2935
+ switch scheme {
2936
+ case "http" :
2937
+ return "80"
2938
+ case "https" :
2939
+ return "443"
2940
+ case "socks5" , "socks5h" :
2941
+ return "1080"
2942
+ default :
2943
+ return ""
2944
+ }
2939
2945
}
2940
2946
2941
2947
func idnaASCIIFromURL (url * url.URL ) string {
@@ -2950,7 +2956,7 @@ func idnaASCIIFromURL(url *url.URL) string {
2950
2956
func canonicalAddr (url * url.URL ) string {
2951
2957
port := url .Port ()
2952
2958
if port == "" {
2953
- port = portMap [ url .Scheme ]
2959
+ port = schemePort ( url .Scheme )
2954
2960
}
2955
2961
return net .JoinHostPort (idnaASCIIFromURL (url ), port )
2956
2962
}
You can’t perform that action at this time.
0 commit comments