当前位置: 首页>>代码示例>>Golang>>正文


Golang RST_STREAM.Status方法代码示例

本文整理汇总了Golang中github.com/SlyMarbo/spdy/spdy3/frames.RST_STREAM.Status方法的典型用法代码示例。如果您正苦于以下问题:Golang RST_STREAM.Status方法的具体用法?Golang RST_STREAM.Status怎么用?Golang RST_STREAM.Status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/SlyMarbo/spdy/spdy3/frames.RST_STREAM的用法示例。


在下文中一共展示了RST_STREAM.Status方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ReceiveFrame

func (p *PushStream) ReceiveFrame(frame common.Frame) error {
	p.Lock()
	defer p.Unlock()

	if frame == nil {
		return errors.New("Error: Nil frame received.")
	}

	// Process the frame depending on its type.
	switch frame := frame.(type) {
	case *frames.WINDOW_UPDATE:
		err := p.flow.UpdateWindow(frame.DeltaWindowSize)
		if err != nil {
			reply := new(frames.RST_STREAM)
			reply.StreamID = p.streamID
			reply.Status = common.RST_STREAM_FLOW_CONTROL_ERROR
			p.output <- reply
			return err
		}

	default:
		return errors.New(fmt.Sprintf("Received unexpected frame of type %T.", frame))
	}

	return nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:26,代码来源:push_stream.go

示例2: shutdown

func (s *RequestStream) shutdown() {
	s.writeHeader()
	if s.state != nil {
		if s.state.OpenThere() {
			// Send the RST_STREAM.
			rst := new(frames.RST_STREAM)
			rst.StreamID = s.streamID
			rst.Status = common.RST_STREAM_CANCEL
			s.output <- rst
		}
		s.state.Close()
	}
	if s.flow != nil {
		s.flow.Close()
	}
	select {
	case <-s.finished:
	default:
		close(s.finished)
	}
	select {
	case <-s.headerChan:
	default:
		close(s.headerChan)
	}
	s.conn.requestStreamLimit.Close()
	s.output = nil
	s.Request = nil
	s.Receiver = nil
	s.header = nil
	s.stop = nil
}
开发者ID:rnapier,项目名称:spdy,代码行数:32,代码来源:request_stream.go

示例3: ReceiveFrame

func (s *ResponseStream) ReceiveFrame(frame common.Frame) error {
	s.Lock()
	defer s.Unlock()

	if frame == nil {
		return errors.New("Error: Nil frame received.")
	}

	// Process the frame depending on its type.
	switch frame := frame.(type) {
	case *frames.DATA:
		s.requestBody.Write(frame.Data)
		s.flow.Receive(frame.Data)
		if frame.Flags.FIN() {
			select {
			case <-s.ready:
			default:
				close(s.ready)
			}
			s.state.CloseThere()
		}

	case *frames.SYN_REPLY:
		common.UpdateHeader(s.header, frame.Header)
		if frame.Flags.FIN() {
			select {
			case <-s.ready:
			default:
				close(s.ready)
			}
			s.state.CloseThere()
		}

	case *frames.HEADERS:
		common.UpdateHeader(s.header, frame.Header)

	case *frames.WINDOW_UPDATE:
		err := s.flow.UpdateWindow(frame.DeltaWindowSize)
		if err != nil {
			reply := new(frames.RST_STREAM)
			reply.StreamID = s.streamID
			reply.Status = common.RST_STREAM_FLOW_CONTROL_ERROR
			s.output <- reply
			return err
		}

	default:
		return errors.New(fmt.Sprintf("Received unknown frame of type %T.", frame))
	}

	return nil
}
开发者ID:rnapier,项目名称:spdy,代码行数:52,代码来源:response_stream.go

示例4: protocolError

// protocolError informs the other endpoint that a protocol error has
// occurred, stops all running streams, and ends the connection.
func (c *Conn) protocolError(streamID common.StreamID) {
	reply := new(frames.RST_STREAM)
	reply.StreamID = streamID
	reply.Status = common.RST_STREAM_PROTOCOL_ERROR
	select {
	case c.output[0] <- reply:
	case <-time.After(100 * time.Millisecond):
		debug.Println("Failed to send PROTOCOL_ERROR RST_STREAM.")
	}
	if c.shutdownError == nil {
		c.shutdownError = reply
	}
	c.Close()
}
开发者ID:vonwenm,项目名称:spdy,代码行数:16,代码来源:error_handling.go

示例5: Receive

// Receive is called when data is received from
// the other endpoint. This ensures that they
// conform to the transfer window, regrows the
// window, and sends errors if necessary.
func (f *flowControl) Receive(data []byte) {
	// The transfer window shouldn't already be negative.
	if f.transferWindowThere < 0 {
		rst := new(frames.RST_STREAM)
		rst.StreamID = f.streamID
		rst.Status = common.RST_STREAM_FLOW_CONTROL_ERROR
		f.output <- rst
	}

	// Update the window.
	f.transferWindowThere -= int64(len(data))

	// Regrow the window if it's half-empty.
	delta := f.flowControl.ReceiveData(f.streamID, f.initialWindowThere, f.transferWindowThere)
	if delta != 0 {
		grow := new(frames.WINDOW_UPDATE)
		grow.StreamID = f.streamID
		grow.DeltaWindowSize = delta
		f.output <- grow
		f.transferWindowThere += int64(grow.DeltaWindowSize)
	}
}
开发者ID:vonwenm,项目名称:spdy,代码行数:26,代码来源:flow.go

示例6: ReceiveFrame

func (s *RequestStream) ReceiveFrame(frame common.Frame) error {
	s.recvMutex.Lock()
	defer s.recvMutex.Unlock()

	if frame == nil {
		return errors.New("Nil frame received.")
	}

	// Process the frame depending on its type.
	switch frame := frame.(type) {
	case *frames.DATA:

		// Extract the data.
		data := frame.Data
		if data == nil {
			data = []byte{}
		}

		// Give to the client.
		s.flow.Receive(frame.Data)
		s.headerChan <- func() {
			s.Receiver.ReceiveData(s.Request, data, frame.Flags.FIN())

			if frame.Flags.FIN() {
				s.state.CloseThere()
				s.Close()
			}
		}

	case *frames.SYN_REPLY:
		s.headerChan <- func() {
			s.Receiver.ReceiveHeader(s.Request, frame.Header)

			if frame.Flags.FIN() {
				s.state.CloseThere()
				s.Close()
			}
		}

	case *frames.HEADERS:
		s.headerChan <- func() {
			s.Receiver.ReceiveHeader(s.Request, frame.Header)

			if frame.Flags.FIN() {
				s.state.CloseThere()
				s.Close()
			}
		}

	case *frames.WINDOW_UPDATE:
		err := s.flow.UpdateWindow(frame.DeltaWindowSize)
		if err != nil {
			reply := new(frames.RST_STREAM)
			reply.StreamID = s.streamID
			reply.Status = common.RST_STREAM_FLOW_CONTROL_ERROR
			s.output <- reply
		}

	default:
		return errors.New(fmt.Sprintf("Received unknown frame of type %T.", frame))
	}

	return nil
}
开发者ID:rnapier,项目名称:spdy,代码行数:64,代码来源:request_stream.go

示例7: _RST_STREAM

func (c *Conn) _RST_STREAM(streamID common.StreamID, status common.StatusCode) {
	rst := new(frames.RST_STREAM)
	rst.StreamID = streamID
	rst.Status = status
	c.output[0] <- rst
}
开发者ID:vonwenm,项目名称:spdy,代码行数:6,代码来源:error_handling.go


注:本文中的github.com/SlyMarbo/spdy/spdy3/frames.RST_STREAM.Status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。