replace usages of session in variable names

This commit is contained in:
Marten Seemann
2022-03-26 15:05:35 +01:00
parent e71c236232
commit fda9f72161
23 changed files with 373 additions and 373 deletions

View File

@@ -84,25 +84,25 @@ type client struct {
quicConf *quic.Config
once sync.Once
sess quic.EarlySession
conn quic.EarlySession
dialErr error
}
func (c *client) RoundTrip(req *http.Request) (*http.Response, error) {
c.once.Do(func() {
c.sess, c.dialErr = quic.DialAddrEarly(c.hostname, c.tlsConf, c.quicConf)
c.conn, c.dialErr = quic.DialAddrEarly(c.hostname, c.tlsConf, c.quicConf)
})
if c.dialErr != nil {
return nil, c.dialErr
}
if req.Method != MethodGet0RTT {
<-c.sess.HandshakeComplete().Done()
<-c.conn.HandshakeComplete().Done()
}
return c.doRequest(req)
}
func (c *client) doRequest(req *http.Request) (*http.Response, error) {
str, err := c.sess.OpenStreamSync(context.Background())
str, err := c.conn.OpenStreamSync(context.Background())
if err != nil {
return nil, err
}
@@ -124,10 +124,10 @@ func (c *client) doRequest(req *http.Request) (*http.Response, error) {
}
func (c *client) Close() error {
if c.sess == nil {
if c.conn == nil {
return nil
}
return c.sess.CloseWithError(0, "")
return c.conn.CloseWithError(0, "")
}
func hostnameFromRequest(req *http.Request) string {

View File

@@ -78,17 +78,17 @@ func (s *Server) ListenAndServe() error {
s.mutex.Unlock()
for {
sess, err := ln.Accept(context.Background())
conn, err := ln.Accept(context.Background())
if err != nil {
return err
}
go s.handleConn(sess)
go s.handleConn(conn)
}
}
func (s *Server) handleConn(sess quic.Connection) {
func (s *Server) handleConn(conn quic.Connection) {
for {
str, err := sess.AcceptStream(context.Background())
str, err := conn.AcceptStream(context.Background())
if err != nil {
log.Printf("Error accepting stream: %s\n", err.Error())
return