MCPcopy Create free account
hub / github.com/53AI/53AIHub / webFetchProxyURLForRequest

Function webFetchProxyURLForRequest

api/service/tools/web_fetch.go:210–245  ·  view source on GitHub ↗
(parsed *url.URL)

Source from the content-addressed store, hash-verified

208}
209
210func webFetchProxyURLForRequest(parsed *url.URL) *url.URL {
211 if parsed == nil {
212 return nil
213 }
214
215 host := strings.TrimSpace(strings.ToLower(parsed.Hostname()))
216 if host == "" {
217 return nil
218 }
219 if host == "localhost" || strings.HasSuffix(host, ".localhost") || isPrivateOrLocalHostname(host) {
220 return nil
221 }
222 if noProxyMatches(host) {
223 return nil
224 }
225
226 scheme := strings.ToLower(strings.TrimSpace(parsed.Scheme))
227 candidates := []string{}
228 if scheme == "https" {
229 candidates = append(candidates, os.Getenv("HTTPS_PROXY"), os.Getenv("https_proxy"))
230 }
231 candidates = append(candidates, os.Getenv("HTTP_PROXY"), os.Getenv("http_proxy"))
232
233 for _, raw := range candidates {
234 raw = strings.TrimSpace(raw)
235 if raw == "" {
236 continue
237 }
238 proxyURL, err := url.Parse(raw)
239 if err != nil || proxyURL == nil {
240 continue
241 }
242 return proxyURL
243 }
244 return nil
245}
246
247func webFetchProxyEnabledForURL(parsed *url.URL) bool {
248 return webFetchProxyURLForRequest(parsed) != nil

Callers 2

executeWebFetchFunction · 0.85

Calls 2

isPrivateOrLocalHostnameFunction · 0.85
noProxyMatchesFunction · 0.85

Tested by

no test coverage detected