MCPcopy Create free account
hub / github.com/imroc/req / foreachHeaderElement

Function foreachHeaderElement

internal/http2/transport.go:2475–2489  ·  view source on GitHub ↗

foreachHeaderElement splits v according to the "#rule" construction in RFC 7230 section 7 and calls fn for each non-empty element.

(v string, fn func(string))

Source from the content-addressed store, hash-verified

2473// foreachHeaderElement splits v according to the "#rule" construction
2474// in RFC 7230 section 7 and calls fn for each non-empty element.
2475func foreachHeaderElement(v string, fn func(string)) {
2476 v = textproto.TrimString(v)
2477 if v == "" {
2478 return
2479 }
2480 if !strings.Contains(v, ",") {
2481 fn(v)
2482 return
2483 }
2484 for _, f := range strings.Split(v, ",") {
2485 if f = textproto.TrimString(f); f != "" {
2486 fn(f)
2487 }
2488 }
2489}
2490
2491// may return error types nil, or ConnectionError. Any other error value
2492// is a StreamError of type ErrCodeProtocol. The returned error in that case

Callers 1

handleResponseMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…