示例#1
0
func (s *ResponseStream) Close() error {
	defer common.Recover()
	s.Lock()
	s.shutdownOnce.Do(s.shutdown)
	s.Unlock()
	return nil
}
示例#2
0
func (p *PushStream) Close() error {
	defer common.Recover()
	p.Lock()
	p.shutdownOnce.Do(p.shutdown)
	p.Unlock()
	return nil
}
示例#3
0
文件: server.go 项目: vonwenm/spdy
func serveSPDYNoNPN(conn net.Conn, srv *http.Server, version, subversion int) {
	defer common.Recover()

	tlsConn, ok := conn.(*tls.Conn)
	if !ok { // Only allow TLS connections.
		return
	}

	if d := srv.ReadTimeout; d != 0 {
		conn.SetReadDeadline(time.Now().Add(d))
	}
	if d := srv.WriteTimeout; d != 0 {
		conn.SetWriteDeadline(time.Now().Add(d))
	}
	if err := tlsConn.Handshake(); err != nil {
		return
	}

	serverConn, err := NewServerConn(tlsConn, srv, version, subversion)
	if err != nil {
		log.Println(err)
		return
	}
	serverConn.Run()
}
示例#4
0
文件: server.go 项目: vonwenm/spdy
func serveSPDY(conn net.Conn, srv *http.Server) {
	defer common.Recover()

	tlsConn, ok := conn.(*tls.Conn)
	if !ok { // Only allow TLS connections.
		return
	}

	if d := srv.ReadTimeout; d != 0 {
		conn.SetReadDeadline(time.Now().Add(d))
	}
	if d := srv.WriteTimeout; d != 0 {
		conn.SetWriteDeadline(time.Now().Add(d))
	}
	if err := tlsConn.Handshake(); err != nil {
		return
	}

	tlsState := new(tls.ConnectionState)
	*tlsState = tlsConn.ConnectionState()
	proto := tlsState.NegotiatedProtocol
	if fn := srv.TLSNextProto[proto]; fn != nil {
		fn(srv, tlsConn, nil)
	}
	return
}
示例#5
0
文件: conn.go 项目: vonwenm/spdy
func (c *Conn) Run() error {
	defer common.Recover()
	go c.send()        // Start the send loop.
	if c.init != nil { // Must be after sending is enabled.
		c.init() // Prepare any initialisation frames.
	}
	go c.readFrames() // Start the main loop.
	<-c.stop          // Run until the connection ends.
	return nil
}
示例#6
0
func (s *RequestStream) processFrames() {
	defer common.Recover()
	for f := range s.headerChan {
		f()
	}
}