func handleHTTPStreams(req *http.Request, w http.ResponseWriter, portForwarder PortForwarder, podName string, uid types.UID, supportedPortForwardProtocols []string, idleTimeout, streamCreationTimeout time.Duration) error { … } // httpStreamReceived is the httpstream.NewStreamHandler for port // forward streams. It checks each stream's port and stream type headers, // rejecting any streams that with missing or invalid values. Each valid // stream is sent to the streams channel. func httpStreamReceived(streams chan httpstream.Stream) func(httpstream.Stream, <-chan struct{ … } type httpStreamHandler … // getStreamPair returns a httpStreamPair for requestID. This creates a // new pair if one does not yet exist for the requestID. The returned bool is // true if the pair was created. func (h *httpStreamHandler) getStreamPair(requestID string) (*httpStreamPair, bool) { … } // monitorStreamPair waits for the pair to receive both its error and data // streams, or for the timeout to expire (whichever happens first), and then // removes the pair. func (h *httpStreamHandler) monitorStreamPair(p *httpStreamPair, timeout <-chan time.Time) { … } // hasStreamPair returns a bool indicating if a stream pair for requestID // exists. func (h *httpStreamHandler) hasStreamPair(requestID string) bool { … } // removeStreamPair removes the stream pair identified by requestID from streamPairs. func (h *httpStreamHandler) removeStreamPair(requestID string) { … } // requestID returns the request id for stream. func (h *httpStreamHandler) requestID(stream httpstream.Stream) string { … } // run is the main loop for the httpStreamHandler. It processes new // streams, invoking portForward for each complete stream pair. The loop exits // when the httpstream.Connection is closed. func (h *httpStreamHandler) run() { … } // portForward invokes the httpStreamHandler's forwarder.PortForward // function for the given stream pair. func (h *httpStreamHandler) portForward(p *httpStreamPair) { … } type httpStreamPair … // newPortForwardPair creates a new httpStreamPair. func newPortForwardPair(requestID string) *httpStreamPair { … } // add adds the stream to the httpStreamPair. If the pair already // contains a stream for the new stream's type, an error is returned. add // returns true if both the data and error streams for this pair have been // received. func (p *httpStreamPair) add(stream httpstream.Stream) (bool, error) { … } // printError writes s to p.errorStream if p.errorStream has been set. func (p *httpStreamPair) printError(s string) { … }