MCPcopy
hub / github.com/caddyserver/caddy / computeApproximateRequestSize

Function computeApproximateRequestSize

modules/caddyhttp/metrics.go:388–410  ·  view source on GitHub ↗

taken from https://github.com/prometheus/client_golang/blob/6007b2b5cae01203111de55f753e76d8dac1f529/prometheus/promhttp/instrument_server.go#L298

(r *http.Request)

Source from the content-addressed store, hash-verified

386
387// taken from https://github.com/prometheus/client_golang/blob/6007b2b5cae01203111de55f753e76d8dac1f529/prometheus/promhttp/instrument_server.go#L298
388func computeApproximateRequestSize(r *http.Request) int {
389 s := 0
390 if r.URL != nil {
391 s += len(r.URL.String())
392 }
393
394 s += len(r.Method)
395 s += len(r.Proto)
396 for name, values := range r.Header {
397 s += len(name)
398 for _, value := range values {
399 s += len(value)
400 }
401 }
402 s += len(r.Host)
403
404 // N.B. r.Form and r.MultipartForm are assumed to be included in r.URL.
405
406 if r.ContentLength != -1 {
407 s += int(r.ContentLength)
408 }
409 return s
410}

Callers 1

ServeHTTPMethod · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected