Ejemplo n.º 1
0
// writeHeader is used to send HTTP headers to
// the client.
func (p *PushStream) writeHeader() {
	if len(p.header) == 0 || p.closed() {
		return
	}

	header := new(frames.HEADERS)
	header.StreamID = p.streamID
	header.Header = common.CloneHeader(p.header)
	for name := range header.Header {
		p.header.Del(name)
	}
	p.output <- header
}
Ejemplo n.º 2
0
// writeHeader is used to flush HTTP headers.
func (s *ResponseStream) writeHeader() {
	if len(s.header) == 0 || s.unidirectional {
		return
	}

	// Create the HEADERS frame.
	header := new(frames.HEADERS)
	header.StreamID = s.streamID
	header.Header = common.CloneHeader(s.header)

	// Clear the headers that have been sent.
	for name := range header.Header {
		s.header.Del(name)
	}

	s.output <- header
}