// Transport that should be used when a custom CA bundle is specified with the
// SDK.
354452
func getCABundleTransport() *http.Transport {
	return &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		DialContext: (&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
			DualStack: true,
		}).DialContext,
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
	}
}
1156576
func NewTransport(token *Token) (*Transport, error) {
	oa, err := token.Assert(new(http.Client))
	if err != nil {
		return nil, err
	}
	return &Transport{
		JWTToken:   token,
		OAuthToken: oa,
	}, nil
}
1370549
func defaultTransport() *http.Transport {
	transport := defaultPooledTransport()
	transport.DisableKeepAlives = true
	transport.MaxIdleConnsPerHost = -1
	return transport
}
504191
func (config *TransportConfig) NewTransport(identity string, exchange pubsub.Exchange) *Transport {
	t := &Transport{
		exchange: exchange,
		identity: identity,
		// Publish call from the exchange must try to avoid blocking as much as
		// possible since blocking here means that the whole exchange is blocked.
		eventCh: make(chan pubsub.Event, config.ChannelCapacity),
		closeCh: make(chan struct{}),
	}

	t.endpoint = &endpointAdapter{t}
	exchange.RegisterEndpoint(t.endpoint)

	return t
}
350749
func (c *Config) transportConfig() *transport.Config {
	return &transport.Config{
		UserAgent:     c.UserAgent,
		Transport:     c.Transport,
		WrapTransport: c.WrapTransport,
		TLS: transport.TLSConfig{
			CAFile:   c.CAFile,
			CAData:   c.CAData,
			CertFile: c.CertFile,
			CertData: c.CertData,
			KeyFile:  c.KeyFile,
			KeyData:  c.KeyData,
			Insecure: c.Insecure,
		},
		Username:    c.Username,
		Password:    c.Password,
		BearerToken: c.BearerToken,
	}
}
490415
func Transport(s string) string {
	switch {
	case strings.HasPrefix(s, TransportTLS+"://"):
		return TransportTLS
	case strings.HasPrefix(s, TransportDNS+"://"):
		return TransportDNS
	case strings.HasPrefix(s, TransportGRPC+"://"):
		return TransportGRPC
	}
	return TransportDNS
}
459783
func (self *HttpClient) SetTransport(tr http.RoundTripper) {
	self.client.Transport = tr
}
1303040
func (p *TransportParameters) Marshal() []byte {
	b := &bytes.Buffer{}
	b.Write([]byte{0, 0}) // length. Will be replaced later

	// initial_max_stream_data_bidi_local
	utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamDataBidiLocalParameterID))
	utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(uint64(p.InitialMaxStreamDataBidiLocal))))
	utils.WriteVarInt(b, uint64(p.InitialMaxStreamDataBidiLocal))
	// initial_max_stream_data_bidi_remote
	utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamDataBidiRemoteParameterID))
	utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(uint64(p.InitialMaxStreamDataBidiRemote))))
	utils.WriteVarInt(b, uint64(p.InitialMaxStreamDataBidiRemote))
	// initial_max_stream_data_uni
	utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamDataUniParameterID))
	utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(uint64(p.InitialMaxStreamDataUni))))
	utils.WriteVarInt(b, uint64(p.InitialMaxStreamDataUni))
	// initial_max_data
	utils.BigEndian.WriteUint16(b, uint16(initialMaxDataParameterID))
	utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(uint64(p.InitialMaxData))))
	utils.WriteVarInt(b, uint64(p.InitialMaxData))
	// initial_max_bidi_streams
	utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamsBidiParameterID))
	utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(p.MaxBidiStreams)))
	utils.WriteVarInt(b, p.MaxBidiStreams)
	// initial_max_uni_streams
	utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamsUniParameterID))
	utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(p.MaxUniStreams)))
	utils.WriteVarInt(b, p.MaxUniStreams)
	// idle_timeout
	idleTimeout := uint64(p.IdleTimeout / time.Millisecond)
	utils.BigEndian.WriteUint16(b, uint16(idleTimeoutParameterID))
	utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(idleTimeout)))
	utils.WriteVarInt(b, idleTimeout)
	// max_packet_size
	utils.BigEndian.WriteUint16(b, uint16(maxPacketSizeParameterID))
	utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(uint64(protocol.MaxReceivePacketSize))))
	utils.WriteVarInt(b, uint64(protocol.MaxReceivePacketSize))
	// ack_delay_exponent
	// Only send it if is different from the default value.
	if p.AckDelayExponent != protocol.DefaultAckDelayExponent {
		utils.BigEndian.WriteUint16(b, uint16(ackDelayExponentParameterID))
		utils.BigEndian.WriteUint16(b, uint16(utils.VarIntLen(uint64(p.AckDelayExponent))))
		utils.WriteVarInt(b, uint64(p.AckDelayExponent))
	}
	// disable_migration
	if p.DisableMigration {
		utils.BigEndian.WriteUint16(b, uint16(disableMigrationParameterID))
		utils.BigEndian.WriteUint16(b, 0)
	}
	if p.StatelessResetToken != nil {
		utils.BigEndian.WriteUint16(b, uint16(statelessResetTokenParameterID))
		utils.BigEndian.WriteUint16(b, 16)
		b.Write(p.StatelessResetToken[:])
	}
	// original_connection_id
	if p.OriginalConnectionID.Len() > 0 {
		utils.BigEndian.WriteUint16(b, uint16(originalConnectionIDParameterID))
		utils.BigEndian.WriteUint16(b, uint16(p.OriginalConnectionID.Len()))
		b.Write(p.OriginalConnectionID.Bytes())
	}

	data := b.Bytes()
	binary.BigEndian.PutUint16(data[:2], uint16(b.Len()-2))
	return data
}
953920
func httpTransport(insecureSkipTLSVerify bool) *http.Transport {
	return &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		Dial: (&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
		}).Dial,
		TLSHandshakeTimeout: 10 * time.Second,
		MaxIdleConns:        10,
		IdleConnTimeout:     15 * time.Second,
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: insecureSkipTLSVerify,
		},
	}
}
334418
func (m *Driver) SendPacket(packet *common.MAVLinkPacket) (err error) {
	_, err = m.adaptor().Write(packet.Pack())
	return err
}
966244
func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) {
	return tf(req)
}
246739
func (t *CustomTransport) RoundTrip(request *http.Request) (*http.Response, error) {
	if len(t.Headers) != 0 {
		for header, value := range t.Headers {
			request.Header.Add(header, value)
		}
	}

	resp, err := t.Transport.RoundTrip(request)

	return resp, err
}
248060
func TransportFor(config *Config) (http.RoundTripper, error) {
	return transport.New(config.transportConfig())
}
1309395
func (c *Collector) WithTransport(transport http.RoundTripper) {
	c.backend.Client.Transport = transport
}
542122
func (h *Host) TransportAddr() string {
	return net.JoinHostPort(h.ip, strconv.Itoa(int(h.port)))
}
1198003
func Transport(tr http.RoundTripper) Option {
	return func(client *http.Client) {
		client.Transport = tr
	}
}
412532
func DefaultTransport() *http.Transport {
	transport := DefaultPooledTransport()
	transport.DisableKeepAlives = true
	transport.MaxIdleConnsPerHost = -1
	return transport
}