Exemplo n.º 1
0
func (stream *SpdyServerStream) OnInitialHeadersComplete(headerBuf []byte) {
	if header, err := spdy.ParseHeaders(bytes.NewReader(headerBuf)); err != nil {
		// TODO(hodduc) should raise proper error
	} else {
		stream.header = header
	}
}
Exemplo n.º 2
0
func (s *SpdyClientStream) ReadHeader() (http.Header, error) {
	if !s.headerParsed {
		// Read until header parsing is successful
		for {
			for s.pendingReads.Empty() {
				s.conn.waitForEvents()
			}

			_, err := s.buf.Write(s.pendingReads.Dequeue().([]byte))
			if err != nil {
				return nil, err
			}

			headerBuf := bytes.NewBuffer(s.buf.Bytes()) // Create a temporary buf just in case for parsing failure
			header, err := spdy.ParseHeaders(headerBuf)
			if err == nil { // If parsing successful
				// XXX(serialx): Is it correct to assume headers are in proper packet frame boundary?
				//               What if theres some parts of body left in headerBuf?
				s.header = header
				s.headerParsed = true
				break
			}
		}
	}

	return s.header, nil
}
Exemplo n.º 3
0
func (stream *SpdyClientStream) OnTrailingHeadersComplete(headerBuf []byte) {
	if header, err := spdy.ParseHeaders(bytes.NewReader(headerBuf)); err != nil {
		// TODO(hodduc) should raise proper error
	} else {
		stream.trailer = header
		stream.trailerParsed = true
	}
}