httptoo

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Default = 0
	Public  = 1
	Private = 2
)
View Source
const StatusClientCancelledRequest = 499

https://httpstatuses.com/499

Variables

This section is empty.

Functions

func AppendURL

func AppendURL(u, v *url.URL) *url.URL

Return the first URL extended with elements of the second, in the manner that occurs throughout my projects. Noteworthy difference from url.URL.ResolveReference is that if the reference has a scheme, the base is not completely ignored.

func ClientTLSConfig

func ClientTLSConfig(cl *http.Client) *tls.Config

Returns the http.Client's TLS Config, traversing and generating any defaults along the way to get it.

func CopyHeaders

func CopyHeaders(w http.ResponseWriter, r *http.Response)

func CopyURL

func CopyURL(u *url.URL) (ret *url.URL)

Deep copies a URL. I could call it DeepCopyURL, but what else would you be copying when you have a *url.URL? Of note is that the Userinfo is deep copied. The returned URL shares no references with the original.

func EncodeQuotedString

func EncodeQuotedString(s string) string

Performs quoted-string from http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html

func ForwardResponse

func ForwardResponse(w http.ResponseWriter, r *http.Response)

func GzipHandler

func GzipHandler(h http.Handler) http.Handler

Gzips response body if the request says it'll allow it.

func NukeCookie

func NukeCookie(w http.ResponseWriter, r *http.Request, name, path string)

Clears the named cookie for every domain that leads to the current one.

func OriginatingProtocol

func OriginatingProtocol(r *http.Request) string

func RedirectedRequest

func RedirectedRequest(r *http.Request, newUrl string) (ret *http.Request, err error)

Takes a request, and alters its destination fields, for proxying.

func RequestIsForLocalhost

func RequestIsForLocalhost(r *http.Request) bool

Request is intended for localhost, either with a localhost name, or loopback IP.

func RequestIsFromLocalhost

func RequestIsFromLocalhost(r *http.Request) bool

Request originated from a loopback IP.

func RequestedURL

func RequestedURL(r *http.Request) (ret *url.URL)

Reconstructs the URL that would have produced the given Request. Request.URLs are not fully populated in http.Server handlers.

func ReverseProxy

func ReverseProxy(w http.ResponseWriter, r *http.Request, originUrl string, client *http.Client) (err error)

func ReverseProxyUpgrade

func ReverseProxyUpgrade(w http.ResponseWriter, r *http.Request, originUrl string) (err error)

w is for the client response. r is the request to send to the origin (already "forwarded"). originUrl is where to send the request.

func RoundTripHandler

func RoundTripHandler(req *http.Request, h http.Handler) (*http.Response, error)

func SetOriginRequestForwardingHeaders

func SetOriginRequestForwardingHeaders(o, f *http.Request)

Types

type AcceptDirective

type AcceptDirective struct {
	MimeType mime.Type
	Q        float64
}

type AcceptDirectives

type AcceptDirectives []AcceptDirective

func ParseAccept

func ParseAccept(line string) (parsed AcceptDirectives, err error)

type BytesContentRange

type BytesContentRange struct {
	First, Last, Length int64
}

func ParseBytesContentRange

func ParseBytesContentRange(s string) (ret BytesContentRange, ok bool)

type BytesRange

type BytesRange struct {
	First, Last int64
}

func ParseBytesRange

func ParseBytesRange(s string) (ret BytesRange, ok bool)

func (BytesRange) String

func (me BytesRange) String() string

type CacheControlHeader

type CacheControlHeader struct {
	MaxAge  time.Duration
	Caching Visibility
	NoStore bool
}

func (CacheControlHeader) String

func (me CacheControlHeader) String() string

type InProcRoundTripper

type InProcRoundTripper struct {
	Handler http.Handler
}

func (*InProcRoundTripper) RoundTrip

func (me *InProcRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type JustFilesFilesystem

type JustFilesFilesystem struct {
	Fs http.FileSystem
}

Wraps a http.FileSystem, disabling directory listings, per the commonly requested feature at https://groups.google.com/forum/#!topic/golang- nuts/bStLPdIVM6w .

func (JustFilesFilesystem) Open

func (fs JustFilesFilesystem) Open(name string) (http.File, error)

type Visibility

type Visibility int

Jump to

Keyboard shortcuts

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