MCPcopy
hub / github.com/grpc/grpc-go / headerHandler

Method headerHandler

internal/transport/controlbuf.go:683–716  ·  view source on GitHub ↗
(h *headerFrame)

Source from the content-addressed store, hash-verified

681}
682
683func (l *loopyWriter) headerHandler(h *headerFrame) error {
684 if l.side == serverSide {
685 str, ok := l.estdStreams[h.streamID]
686 if !ok {
687 if l.logger.V(logLevel) {
688 l.logger.Infof("Unrecognized streamID %d in loopyWriter", h.streamID)
689 }
690 return nil
691 }
692 // Case 1.A: Server is responding back with headers.
693 if !h.endStream {
694 return l.writeHeader(h.streamID, h.endStream, h.hf, h.onWrite)
695 }
696 // else: Case 1.B: Server wants to close stream.
697
698 if str.state != empty { // either active or waiting on stream quota.
699 // add it str's list of items.
700 str.itl.enqueue(h)
701 return nil
702 }
703 if err := l.writeHeader(h.streamID, h.endStream, h.hf, h.onWrite); err != nil {
704 return err
705 }
706 return l.cleanupStreamHandler(h.cleanup)
707 }
708 // Case 2: Client wants to originate stream.
709 str := &outStream{
710 id: h.streamID,
711 state: empty,
712 itl: &itemList{},
713 wq: h.wq,
714 }
715 return l.originateStream(str, h)
716}
717
718func (l *loopyWriter) originateStream(str *outStream, hdr *headerFrame) error {
719 // l.draining is set when handling GoAway. In which case, we want to avoid

Callers 1

handleMethod · 0.95

Calls 6

writeHeaderMethod · 0.95
cleanupStreamHandlerMethod · 0.95
originateStreamMethod · 0.95
VMethod · 0.65
InfofMethod · 0.65
enqueueMethod · 0.45

Tested by

no test coverage detected