Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MockTransport http.RoundTripper
MockTransport can be set during tests to intercept all HTTP/HTTPS requests created by UniRTM's DefaultTransport.
var ProxyBypassDomains = []string{
"aliyun.com",
"npmmirror.com",
"tencent.com",
"huaweicloud.com",
"163.com",
"ustc.edu.cn",
"tsinghua.edu.cn",
"sjtu.edu.cn",
"bfsu.edu.cn",
"lzu.edu.cn",
"nju.edu.cn",
"cqu.edu.cn",
"hit.edu.cn",
"zju.edu.cn",
"douban.com",
"rsproxy.cn",
"r.cnpmjs.org",
"goproxy.cn",
"goproxy.io",
"gems.ruby-china.com",
"sn0wdr1am.com",
}
ProxyBypassDomains contains a list of common domestic mirror domains that should bypass any configured HTTP proxies to prevent connection drops.
Functions ¶
func DefaultTransport ¶
DefaultTransport returns UniRTM's standard http.Transport.
It customizes two behaviors that Go's default transport cannot provide:
Smart Proxy Bypass: domestic mirror domains (aliyun.com, npmmirror.com, etc.) are forced to use DIRECT connections, preventing local proxy software from returning "Bad Request" errors when routing Chinese CDN traffic.
UNIRTM_/MISE_ env prefix support: reads HTTP_PROXY/HTTPS_PROXY/ALL_PROXY through env.Get(), which resolves UNIRTM_HTTP_PROXY and MISE_HTTP_PROXY in addition to the standard names that http.ProxyFromEnvironment covers.
All other settings (connection pool, timeouts) are inherited from Go's http.DefaultTransport via Clone(), so they stay in sync with upstream defaults.
func DisableHTTP2 ¶
DisableHTTP2 safely disables HTTP/2 on the given transport. This prevents ALPN framing errors when proxies intercept traffic.
func NewClientWithTimeout ¶
NewClientWithTimeout returns an http.Client with a timeout and the robust transport.
func ShouldBypassProxy ¶
ShouldBypassProxy returns true if the given host should bypass the proxy.
Types ¶
This section is empty.