MCPcopy Create free account
hub / github.com/google/pprof / fetchURL

Function fetchURL

internal/driver/fetch.go:525–540  ·  view source on GitHub ↗

fetchURL fetches a profile from a URL using HTTP.

(source string, timeout time.Duration, tr http.RoundTripper)

Source from the content-addressed store, hash-verified

523
524// fetchURL fetches a profile from a URL using HTTP.
525func fetchURL(source string, timeout time.Duration, tr http.RoundTripper) (io.ReadCloser, error) {
526 client := &http.Client{
527 Transport: tr,
528 Timeout: timeout + 5*time.Second,
529 }
530 resp, err := client.Get(source)
531 if err != nil {
532 return nil, fmt.Errorf("http fetch: %v", err)
533 }
534 if resp.StatusCode != http.StatusOK {
535 defer resp.Body.Close()
536 return nil, statusCodeError(resp)
537 }
538
539 return resp.Body, nil
540}
541
542func statusCodeError(resp *http.Response) error {
543 if resp.Header.Get("X-Go-Pprof") != "" && strings.Contains(resp.Header.Get("Content-Type"), "text/plain") {

Callers 1

fetchFunction · 0.85

Calls 2

statusCodeErrorFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…