Documentation ¶
Overview ¶
Package proxyutil provides functionality for building proxies.
Index ¶
- Variables
- func FixBadFraming(header http.Header) error
- func NewErrorResponse(code int, err error, req *http.Request) *http.Response
- func NewResponse(code int, body io.Reader, req *http.Request) *http.Response
- func RemoveHopByHopHeaders(header http.Header)
- func SetForwardedHeaders(req *http.Request)
- func SetViaHeader(header http.Header, via string)
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
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 ¶
NewErrorResponse builds new HTTP error responses.
func NewResponse ¶
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 ¶
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 ¶
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 ¶
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.