roundtripper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	H2CPriorKnowledgeProtocol = "H2C_PRIOR_KNOWLEDGE"
)

Variables

This section is empty.

Functions

func IsRedirect added in v0.6.0

func IsRedirect(statusCode int) bool

IsRedirect returns true if a given status code is a redirect code.

func IsTimeoutError added in v1.0.0

func IsTimeoutError(statusCode int) bool

IsTimeoutError returns true if a given status code is a timeout error code.

Types

type CapturedRequest

type CapturedRequest struct {
	Path     string              `json:"path"`
	Host     string              `json:"host"`
	Method   string              `json:"method"`
	Protocol string              `json:"proto"`
	Headers  map[string][]string `json:"headers"`

	Namespace string `json:"namespace"`
	Pod       string `json:"pod"`
}

CapturedRequest contains request metadata captured from an echoserver response.

type CapturedResponse

type CapturedResponse struct {
	StatusCode      int
	ContentLength   int64
	Protocol        string
	Headers         map[string][]string
	RedirectRequest *RedirectRequest
}

CapturedResponse contains response metadata.

type DefaultRoundTripper

type DefaultRoundTripper struct {
	Debug             bool
	TimeoutConfig     config.TimeoutConfig
	CustomDialContext func(context.Context, string, string) (net.Conn, error)
}

DefaultRoundTripper is the default implementation of a RoundTripper. It will be used if a custom implementation is not specified.

func (*DefaultRoundTripper) CaptureRoundTrip

func (d *DefaultRoundTripper) CaptureRoundTrip(request Request) (*CapturedRequest, *CapturedResponse, error)

CaptureRoundTrip makes a request with the provided parameters and returns the captured request and response from echoserver. An error will be returned if there is an error running the function but not if an HTTP error status code is received.

type RedirectRequest added in v0.6.0

type RedirectRequest struct {
	Scheme string
	Host   string
	Port   string
	Path   string
}

RedirectRequest contains a follow up request metadata captured from a redirect response.

type Request

type Request struct {
	URL              url.URL
	Host             string
	Protocol         string
	Method           string
	Headers          map[string][]string
	UnfollowRedirect bool
	CertPem          []byte
	KeyPem           []byte
	Server           string
}

Request is the primary input for making a request.

func (Request) String added in v0.7.0

func (r Request) String() string

String returns a printable version of Request for logging. Note that the CertPem and KeyPem are truncated.

type RoundTripper

type RoundTripper interface {
	CaptureRoundTrip(Request) (*CapturedRequest, *CapturedResponse, error)
}

RoundTripper is an interface used to make requests within conformance tests. This can be overridden with custom implementations whenever necessary.

Jump to

Keyboard shortcuts

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