示例#1
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 = make(http.Header)

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

	s.output <- header
}
示例#2
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 = make(http.Header)

	for name, values := range p.header {
		for _, value := range values {
			header.Header.Add(name, value)
		}
		p.header.Del(name)
	}

	if len(header.Header) == 0 {
		return
	}

	p.output <- header
}