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

Method processData

internal/http2/transport.go:2752–2866  ·  view source on GitHub ↗
(f *DataFrame)

Source from the content-addressed store, hash-verified

2750}
2751
2752func (rl *clientConnReadLoop) processData(f *DataFrame) error {
2753 cc := rl.cc
2754 cs := rl.streamByID(f.StreamID)
2755 data := f.Data()
2756 if cs == nil {
2757 cc.mu.Lock()
2758 neverSent := cc.nextStreamID
2759 cc.mu.Unlock()
2760 if f.StreamID >= neverSent {
2761 // We never asked for this.
2762 cc.logf("http2: Transport received unsolicited DATA frame; closing connection")
2763 return ConnectionError(ErrCodeProtocol)
2764 }
2765 // We probably did ask for this, but canceled. Just ignore it.
2766 // TODO: be stricter here? only silently ignore things which
2767 // we canceled, but not things which were closed normally
2768 // by the peer? Tough without accumulating too much state.
2769
2770 // But at least return their flow control:
2771 if f.Length > 0 {
2772 cc.mu.Lock()
2773 ok := cc.inflow.take(f.Length)
2774 connAdd := cc.inflow.add(int(f.Length))
2775 cc.mu.Unlock()
2776 if !ok {
2777 return ConnectionError(ErrCodeFlowControl)
2778 }
2779 if connAdd > 0 {
2780 cc.wmu.Lock()
2781 cc.fr.WriteWindowUpdate(0, uint32(connAdd))
2782 cc.bw.Flush()
2783 cc.wmu.Unlock()
2784 }
2785 }
2786 return nil
2787 }
2788 if cs.readClosed {
2789 cc.logf("protocol error: received DATA after END_STREAM")
2790 rl.endStreamError(cs, StreamError{
2791 StreamID: f.StreamID,
2792 Code: ErrCodeProtocol,
2793 })
2794 return nil
2795 }
2796 if !cs.pastHeaders {
2797 cc.logf("protocol error: received DATA before a HEADERS frame")
2798 rl.endStreamError(cs, StreamError{
2799 StreamID: f.StreamID,
2800 Code: ErrCodeProtocol,
2801 })
2802 return nil
2803 }
2804 if f.Length > 0 {
2805 if cs.isHead && len(data) > 0 {
2806 cc.logf("protocol error: received DATA on a HEAD request")
2807 rl.endStreamError(cs, StreamError{
2808 StreamID: f.StreamID,
2809 Code: ErrCodeProtocol,

Callers 1

runMethod · 0.95

Calls 14

streamByIDMethod · 0.95
endStreamErrorMethod · 0.95
endStreamMethod · 0.95
ConnectionErrorTypeAlias · 0.85
takeInflowsFunction · 0.85
DataMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
WriteWindowUpdateMethod · 0.80
WriteMethod · 0.65
StreamEndedMethod · 0.65
logfMethod · 0.45

Tested by

no test coverage detected