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

Method processTrailers

internal/http2/transport.go:2626–2652  ·  view source on GitHub ↗
(cs *clientStream, f *MetaHeadersFrame)

Source from the content-addressed store, hash-verified

2624}
2625
2626func (rl *clientConnReadLoop) processTrailers(cs *clientStream, f *MetaHeadersFrame) error {
2627 if cs.pastTrailers {
2628 // Too many HEADERS frames for this stream.
2629 return ConnectionError(ErrCodeProtocol)
2630 }
2631 cs.pastTrailers = true
2632 if !f.StreamEnded() {
2633 // We expect that any headers for trailers also
2634 // has END_STREAM.
2635 return ConnectionError(ErrCodeProtocol)
2636 }
2637 if len(f.PseudoFields()) > 0 {
2638 // No pseudo header fields are defined for trailers.
2639 // TODO: ConnectionError might be overly harsh? Check.
2640 return ConnectionError(ErrCodeProtocol)
2641 }
2642
2643 trailer := make(http.Header)
2644 for _, hf := range f.RegularFields() {
2645 key := canonicalHeader(hf.Name)
2646 trailer[key] = append(trailer[key], hf.Value)
2647 }
2648 cs.trailer = trailer
2649
2650 rl.endStream(cs)
2651 return nil
2652}
2653
2654// transportResponseBody is the concrete type of Transport.RoundTrip's
2655// Response.Body. It is an io.ReadCloser.

Callers 1

processHeadersMethod · 0.95

Calls 6

endStreamMethod · 0.95
ConnectionErrorTypeAlias · 0.85
canonicalHeaderFunction · 0.85
PseudoFieldsMethod · 0.80
RegularFieldsMethod · 0.80
StreamEndedMethod · 0.65

Tested by

no test coverage detected