Example #1
0
func (s *ResponseStream) Close() error {
	defer common.Recover()
	s.Lock()
	s.shutdownOnce.Do(s.shutdown)
	s.Unlock()
	return nil
}
Example #2
0
func (p *PushStream) Close() error {
	defer common.Recover()
	p.Lock()
	p.shutdownOnce.Do(p.shutdown)
	p.Unlock()
	return nil
}
Example #3
0
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()
}
Example #4
0
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
}
Example #5
0
File: conn.go Project: 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
}
Example #6
0
func (s *RequestStream) processFrames() {
	defer common.Recover()
	for f := range s.headerChan {
		f()
	}
}