proxyutil

package
v3.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Overview

Package proxyutil provides functionality for building proxies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRangeStart

func GetRangeStart(res *http.Response) int64

GetRangeStart returns the byte index of the start of the range, if it has one. Returns 0 if the range header is absent, and -1 if the range header is invalid or has multi-part ranges.

func NewResponse

func NewResponse(code int, body io.Reader, req *http.Request) *http.Response

NewResponse builds new HTTP responses. If body is nil, an empty byte.Buffer will be provided to be consistent with the guarantees provided by http.Transport and http.Client.

func Warning

func Warning(header http.Header, err error)

Warning adds an error to the Warning header in the format: 199 "martian" "error message" "date".

Types

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

Header is a generic representation of a set of HTTP headers for requests and responses.

func RequestHeader

func RequestHeader(req *http.Request) *Header

RequestHeader returns a new set of headers from a request.

func ResponseHeader

func ResponseHeader(res *http.Response) *Header

ResponseHeader returns a new set of headers from a request.

func (*Header) Add

func (h *Header) Add(name, value string) error

Add appends the value to the existing header at name for the request or response.

func (*Header) All

func (h *Header) All(name string) ([]string, bool)

All returns all the values for header name. If the header does not exist it returns nil, false.

func (*Header) Del

func (h *Header) Del(name string)

Del deletes the header at name for the request or response.

func (*Header) Get

func (h *Header) Get(name string) string

Get returns the first value at header name for the request or response.

func (*Header) Map

func (h *Header) Map() http.Header

Map returns an http.Header that includes Host, Content-Length, and Transfer-Encoding.

func (*Header) Set

func (h *Header) Set(name, value string) error

Set sets value at header name for the request or response.

Jump to

Keyboard shortcuts

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