mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-04 07:45:30 +00:00
temp
This commit is contained in:
@@ -2,6 +2,7 @@ package util
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -51,3 +52,14 @@ func BuildProxyUrl(scheme, host, usr, pwd string) *url.URL {
|
||||
Host: host,
|
||||
}
|
||||
}
|
||||
|
||||
// ProxyUrlToHandler gets the proxy handler from the proxy url.
|
||||
func ProxyUrlToHandler(proxyUrl *url.URL) func(*http.Request) (*url.URL, error) {
|
||||
if proxyUrl == nil {
|
||||
return nil
|
||||
}
|
||||
if proxyUrl.Scheme == "system" {
|
||||
return http.ProxyFromEnvironment
|
||||
}
|
||||
return http.ProxyURL(proxyUrl)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user