proxyutil

package
v0.0.0-...-c724f24 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package proxyutil provides functionality for building proxies.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadFraming = errors.New("bad request framing")

ErrBadFraming is an error returned when it is impossible to determine how to properly terminate a request. This often occurs becaue of conflicting Content-Length headers or a non-chunked Transfer-Encoding without a Content-Length.

View Source
var HopByHopHeaders = []string{
	"Connection",
	"Keep-Alive",
	"Proxy-Authenticate",
	"Proxy-Authorization",
	"Te",
	"Trailer",
	"Transfer-Encoding",
	"Upgrade",
}

Hop-by-hop headers as defined by RFC2616.

http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-7.1.3.1

Functions

func FixBadFraming

func FixBadFraming(header http.Header) error

FixBadFraming makes a best effort to fix inconsistencies in the request such as multiple Content-Lengths or the lack of Content-Length and improper Transfer-Encoding. If it is unable to determine a proper resolution it returns ErrBadFraming.

http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-3.3

func NewErrorResponse

func NewErrorResponse(code int, err error, req *http.Request) *http.Response

NewErrorResponse builds new HTTP error responses.

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 RemoveHopByHopHeaders

func RemoveHopByHopHeaders(header http.Header)

RemoveHopByHopHeaders removes all hop-by-hop headers defined by RFC2616 as well as any additional hop-by-hop headers specified in the Connection header.

func SetForwardedHeaders

func SetForwardedHeaders(req *http.Request)

SetForwardedHeaders sets the X-Fowarded-Proto and X-Forwarded-For headers for the outgoing request.

If X-Forwarded-For is already present, the client IP is appended to the existing value.

func SetViaHeader

func SetViaHeader(header http.Header, via string)

SetViaHeader sets the Via header.

If Via is already present, via is appended to the existing value.

http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-9.9

Types

This section is empty.

Jump to

Keyboard shortcuts

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