Пример #1
0
func (t *http2Client) getStream(f http2.Frame) (*Stream, bool) {
	t.mu.Lock()
	defer t.mu.Unlock()
	if t.activeStreams == nil {
		// The transport is closing.
		return nil, false
	}
	if s, ok := t.activeStreams[f.Header().StreamID]; ok {
		return s, true
	}
	return nil, false
}
Пример #2
0
func (t *http2Server) getStream(f http2.Frame) (*Stream, bool) {
	t.mu.Lock()
	defer t.mu.Unlock()
	if t.activeStreams == nil {
		// The transport is closing.
		return nil, false
	}
	s, ok := t.activeStreams[f.Header().StreamID]
	if !ok {
		// The stream is already done.
		return nil, false
	}
	return s, true
}
Пример #3
0
func CreateResultFrame(f http2.Frame) (rf *ResultFrame) {
	rf = &ResultFrame{
		Type:   f.Header().Type,
		Flags:  f.Header().Flags,
		Length: f.Header().Length,
	}

	switch f := f.(type) {
	case *http2.GoAwayFrame:
		rf.ErrCode = f.ErrCode
	case *http2.RSTStreamFrame:
		rf.ErrCode = f.ErrCode
	default:
		rf.ErrCode = ErrCodeDefault
	}

	return rf
}