gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

go115.go (688B)


      1 // Copyright 2021 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 //go:build go1.15
      6 // +build go1.15
      7 
      8 package http2
      9 
     10 import (
     11 	"context"
     12 	"crypto/tls"
     13 )
     14 
     15 // dialTLSWithContext uses tls.Dialer, added in Go 1.15, to open a TLS
     16 // connection.
     17 func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) {
     18 	dialer := &tls.Dialer{
     19 		Config: cfg,
     20 	}
     21 	cn, err := dialer.DialContext(ctx, network, addr)
     22 	if err != nil {
     23 		return nil, err
     24 	}
     25 	tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed
     26 	return tlsCn, nil
     27 }