MCPcopy Create free account
hub / github.com/diillson/chatcli / webGet

Function webGet

cli/plugins/builtin_web_httpclient.go:89–100  ·  view source on GitHub ↗

webGet issues a GET to url through the shared proxy/SSRF-aware client with the given extra headers (User-Agent is managed here, do not pass it). It sends a browser User-Agent by default so public CDNs (Cloudflare/Mintlify) don't bot-block it with a 403. If the response is a gateway auth challenge (4

(ctx context.Context, url string, extraHeaders map[string]string)

Source from the content-addressed store, hash-verified

87// gateways allow through. An explicit CHATCLI_WEBFETCH_USER_AGENT disables the
88// fallback, since the user chose that UA deliberately.
89func webGet(ctx context.Context, url string, extraHeaders map[string]string) (*http.Response, error) {
90 resp, err := webGetWithUA(ctx, url, browserUA(), extraHeaders)
91 if err != nil {
92 return nil, err
93 }
94 if (resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusProxyAuthRequired) &&
95 strings.TrimSpace(os.Getenv("CHATCLI_WEBFETCH_USER_AGENT")) == "" {
96 _ = resp.Body.Close()
97 return webGetWithUA(ctx, url, fallbackUserAgent, extraHeaders)
98 }
99 return resp, nil
100}
101
102// webGetWithUA performs a single GET with the given User-Agent and headers.
103//

Callers 7

fetchSearchHTMLFunction · 0.85
fetchDocsFlattenPageFunction · 0.85
searchSearxNGFunction · 0.85
searchDuckDuckGoFunction · 0.85
ExecuteWithStreamMethod · 0.85

Calls 3

webGetWithUAFunction · 0.85
browserUAFunction · 0.85
CloseMethod · 0.65