crhchttp

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTransport = &http.Transport{
	Proxy: http.ProxyFromEnvironment,
	DialContext: (&net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
		DualStack: true,
	}).DialContext,
	ForceAttemptHTTP2:     true,
	MaxIdleConns:          100,
	IdleConnTimeout:       90 * time.Second,
	TLSHandshakeTimeout:   10 * time.Second,
	ExpectContinueTimeout: 1 * time.Second,
}

DefaultTransport is a copy from the golang http package

Functions

func GetMultiPartBodyAndHeaders

func GetMultiPartBodyAndHeaders(filename string) (*bytes.Buffer, string, error)

GetMultiPartBodyAndHeaders Get multi-part body and headers for upload

func ProcessResponse

func ProcessResponse(logger logr.Logger, resp *http.Response) ([]byte, error)

ProcessResponse Log response for request and return valid

func SetupRequest

func SetupRequest(authConfig *AuthConfig, contentType, method, uri string, body *bytes.Buffer) (*http.Request, error)

SetupRequest creates a new request, adds headers to request object for communication to cloud.redhat.com, and returns the request

func Upload

func Upload(authConfig *AuthConfig, contentType, method, uri string, body *bytes.Buffer, fileInfo packaging.FileInfoManifest, file string) (string, metav1.Time, string, error)

Upload Send data to cloud.redhat.com

Types

type AuthConfig

type AuthConfig struct {
	Client            client.Client
	ClusterID         string
	Authentication    kokumetricscfgv1beta1.AuthenticationType
	BearerTokenString string
	BasicAuthUser     string
	BasicAuthPassword string
	ValidateCert      bool
	OperatorCommit    string
	Log               logr.Logger
}

AuthConfig provides the data for reconciling the CR with defaults

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient gives us a testable interface

var Client HTTPClient

Client is an http.Client

func GetClient

func GetClient(authConfig *AuthConfig) HTTPClient

GetClient Return client with certificate handling based on configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL