http

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResponseTooLong = errors.New("response too long")

Functions

func DrainBody

func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)

DrainBody is from httputil.

func FlattenResponse

func FlattenResponse(request *http.Request, response *http.Response, maxSize int64) (map[string]any, error)

FlattenResponse reads response body to a new map[string]any with a flat hierarchy.

func IsValidStatusCode

func IsValidStatusCode(code int) bool

func ReadResponse

func ReadResponse(response *http.Response, maxSize int64) ([]byte, error)

func ValidateStatusCode

func ValidateStatusCode(
	request *http.Request,
	response *http.Response,
	resErrMsgKey string,
	maxSize int64,
) error

ValidateStatusCode checks response status code and generates error if status code is not allowed.

Types

type Doer

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

type ResponseError

type ResponseError struct {
	// contains filtered or unexported fields
}

func NewResponseError

func NewResponseError(err error, failReason string) *ResponseError

func (*ResponseError) Error

func (e *ResponseError) Error() string

func (*ResponseError) FailReason

func (e *ResponseError) FailReason() string

func (*ResponseError) Unwrap

func (e *ResponseError) Unwrap() error

Jump to

Keyboard shortcuts

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