var ErrIllegalHeaderWrite … var ErrHeaderListSizeLimitViolation … var serverConnectionCounter … type http2Server … // NewServerTransport creates a http2 transport with conn and configuration // options from config. // // It returns a non-nil transport and a nil error on success. On failure, it // returns a nil transport and a non-nil error. For a special case where the // underlying conn gets closed before the client preface could be read, it // returns a nil transport and a nil error. func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport, err error) { … } // operateHeaders takes action on the decoded headers. Returns an error if fatal // error encountered and transport needs to close, otherwise returns nil. func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeadersFrame, handle func(*Stream)) error { … } // HandleStreams receives incoming streams using the given handler. This is // typically run in a separate goroutine. // traceCtx attaches trace to ctx and returns the new context. func (t *http2Server) HandleStreams(ctx context.Context, handle func(*Stream)) { … } func (t *http2Server) getStream(f http2.Frame) (*Stream, bool) { … } // adjustWindow sends out extra window update over the initial window size // of stream if the application is requesting data larger in size than // the window. func (t *http2Server) adjustWindow(s *Stream, n uint32) { … } // updateWindow adjusts the inbound quota for the stream and the transport. // Window updates will deliver to the controller for sending when // the cumulative quota exceeds the corresponding threshold. func (t *http2Server) updateWindow(s *Stream, n uint32) { … } // updateFlowControl updates the incoming flow control windows // for the transport and the stream based on the current bdp // estimation. func (t *http2Server) updateFlowControl(n uint32) { … } func (t *http2Server) handleData(f *http2.DataFrame) { … } func (t *http2Server) handleRSTStream(f *http2.RSTStreamFrame) { … } func (t *http2Server) handleSettings(f *http2.SettingsFrame) { … } const maxPingStrikes … const defaultPingTimeout … func (t *http2Server) handlePing(f *http2.PingFrame) { … } func (t *http2Server) handleWindowUpdate(f *http2.WindowUpdateFrame) { … } func appendHeaderFieldsFromMD(headerFields []hpack.HeaderField, md metadata.MD) []hpack.HeaderField { … } func (t *http2Server) checkForHeaderListSize(it any) bool { … } func (t *http2Server) streamContextErr(s *Stream) error { … } // WriteHeader sends the header metadata md back to the client. func (t *http2Server) WriteHeader(s *Stream, md metadata.MD) error { … } func (t *http2Server) setResetPingStrikes() { … } func (t *http2Server) writeHeaderLocked(s *Stream) error { … } // WriteStatus sends stream status to the client and terminates the stream. // There is no further I/O operations being able to perform on this stream. // TODO(zhaoq): Now it indicates the end of entire stream. Revisit if early // OK is adopted. func (t *http2Server) WriteStatus(s *Stream, st *status.Status) error { … } // Write converts the data into HTTP2 data frame and sends it out. Non-nil error // is returns if it fails (e.g., framing error, transport error). func (t *http2Server) Write(s *Stream, hdr []byte, data []byte, opts *Options) error { … } // keepalive running in a separate goroutine does the following: // 1. Gracefully closes an idle connection after a duration of keepalive.MaxConnectionIdle. // 2. Gracefully closes any connection after a duration of keepalive.MaxConnectionAge. // 3. Forcibly closes a connection after an additive period of keepalive.MaxConnectionAgeGrace over keepalive.MaxConnectionAge. // 4. Makes sure a connection is alive by sending pings with a frequency of keepalive.Time and closes a non-responsive connection // after an additional duration of keepalive.Timeout. func (t *http2Server) keepalive() { … } // Close starts shutting down the http2Server transport. // TODO(zhaoq): Now the destruction is not blocked on any pending streams. This // could cause some resource issue. Revisit this later. func (t *http2Server) Close(err error) { … } // deleteStream deletes the stream s from transport's active streams. func (t *http2Server) deleteStream(s *Stream, eosReceived bool) { … } // finishStream closes the stream and puts the trailing headerFrame into controlbuf. func (t *http2Server) finishStream(s *Stream, rst bool, rstCode http2.ErrCode, hdr *headerFrame, eosReceived bool) { … } // closeStream clears the footprint of a stream when the stream is not needed any more. func (t *http2Server) closeStream(s *Stream, rst bool, rstCode http2.ErrCode, eosReceived bool) { … } func (t *http2Server) Drain(debugData string) { … } var goAwayPing … // Handles outgoing GoAway and returns true if loopy needs to put itself // in draining mode. func (t *http2Server) outgoingGoAwayHandler(g *goAway) (bool, error) { … } func (t *http2Server) socketMetrics() *channelz.EphemeralSocketMetrics { … } func (t *http2Server) IncrMsgSent() { … } func (t *http2Server) IncrMsgRecv() { … } func (t *http2Server) getOutFlowWindow() int64 { … } // Peer returns the peer of the transport. func (t *http2Server) Peer() *peer.Peer { … } func getJitter(v time.Duration) time.Duration { … } type connectionKey … // GetConnection gets the connection from the context. func GetConnection(ctx context.Context) net.Conn { … } // SetConnection adds the connection to the context to be able to get // information about the destination ip and port for an incoming RPC. This also // allows any unary or streaming interceptors to see the connection. func SetConnection(ctx context.Context, conn net.Conn) context.Context { … }