http

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderXForwardedMethod = "X-Forwarded-Method"
	HeaderXForwardedFor    = "X-Forwarded-For"
	HeaderXForwardedProto  = "X-Forwarded-Proto"
	HeaderXForwardedHost   = "X-Forwarded-Host"
	HeaderXForwardedPort   = "X-Forwarded-Port"
	HeaderXForwardedURI    = "X-Forwarded-Uri"
	HeaderXRealIP          = "X-Real-IP"

	HeaderUpstreamName   = "X-GoDoxy-Upstream-Name"
	HeaderUpstreamScheme = "X-GoDoxy-Upstream-Scheme"
	HeaderUpstreamHost   = "X-GoDoxy-Upstream-Host"
	HeaderUpstreamPort   = "X-GoDoxy-Upstream-Port"

	HeaderContentType   = "Content-Type"
	HeaderContentLength = "Content-Length"
)
View Source
const StaticFilePathPrefix = "/$gperrorpage/"

Variables

View Source
var (
	DefaultTransport = &http.Transport{
		Proxy:                 http.ProxyFromEnvironment,
		DialContext:           defaultDialer.DialContext,
		ForceAttemptHTTP2:     true,
		MaxIdleConnsPerHost:   100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
		DisableCompression:    true,
		ResponseHeaderTimeout: 60 * time.Second,
		WriteBufferSize:       16 * 1024,
		ReadBufferSize:        16 * 1024,
	}
	DefaultTransportNoTLS = func() *http.Transport {
		clone := DefaultTransport.Clone()
		clone.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
		return clone
	}()
)

Functions

func CopyHeader

func CopyHeader(dst, src http.Header)

func FilterHeaders

func FilterHeaders(h http.Header, allowed []string) http.Header

func HeaderToMap

func HeaderToMap(h http.Header) map[string]string

func IsMethodValid

func IsMethodValid(method string) bool

func IsStatusCodeValid

func IsStatusCodeValid(status int) bool

func IsSuccess

func IsSuccess(status int) bool

func RemoveHop

func RemoveHop(h http.Header)

func RemoveHopByHopHeaders

func RemoveHopByHopHeaders(h http.Header)

RemoveHopByHopHeaders removes hop-by-hop headers.

func UpgradeType

func UpgradeType(h http.Header) string

Types

type AcceptContentType

type AcceptContentType []ContentType

func GetAccept

func GetAccept(h http.Header) AcceptContentType

func (AcceptContentType) AcceptHTML

func (act AcceptContentType) AcceptHTML() bool

func (AcceptContentType) AcceptJSON

func (act AcceptContentType) AcceptJSON() bool

func (AcceptContentType) AcceptPlainText

func (act AcceptContentType) AcceptPlainText() bool

func (AcceptContentType) IsEmpty

func (act AcceptContentType) IsEmpty() bool

type ContentType

type ContentType string

func GetContentType

func GetContentType(h http.Header) ContentType

func (ContentType) IsHTML

func (ct ContentType) IsHTML() bool

func (ContentType) IsJSON

func (ct ContentType) IsJSON() bool

func (ContentType) IsPlainText

func (ct ContentType) IsPlainText() bool

type ModifyResponseFunc

type ModifyResponseFunc func(*http.Response) error

type ModifyResponseWriter

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

func (*ModifyResponseWriter) Flush

func (w *ModifyResponseWriter) Flush()

Flush sends any buffered data to the client.

func (*ModifyResponseWriter) Header

func (w *ModifyResponseWriter) Header() http.Header

func (*ModifyResponseWriter) Hijack

Hijack hijacks the connection.

func (*ModifyResponseWriter) Size

func (w *ModifyResponseWriter) Size() int

func (*ModifyResponseWriter) StatusCode

func (w *ModifyResponseWriter) StatusCode() int

func (*ModifyResponseWriter) Unwrap

func (*ModifyResponseWriter) Write

func (w *ModifyResponseWriter) Write(b []byte) (int, error)

func (*ModifyResponseWriter) WriteHeader

func (w *ModifyResponseWriter) WriteHeader(code int)

type ServeMux

type ServeMux struct {
	*http.ServeMux
}

func NewServeMux

func NewServeMux() ServeMux

func (ServeMux) Handle

func (mux ServeMux) Handle(pattern string, handler http.Handler) (err error)

func (ServeMux) HandleFunc

func (mux ServeMux) HandleFunc(pattern string, handler http.HandlerFunc) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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