Documentation ¶
Overview ¶
Package headers provides functionality for HTTP Headers not provided by the builtin net/http package
Index ¶
- Constants
- Variables
- func AddForwarded(r *http.Request, hop *Hop)
- func AddForwardedAndX(r *http.Request, hop *Hop)
- func AddForwardingHeaders(r *http.Request, headerType string)
- func AddResponseHeaders(h http.Header)
- func AddXForwarded(r *http.Request, hop *Hop)
- func ExtractHeader(headers http.Header, header string) (string, bool)
- func HideAuthorizationCredentials(headers Lookup)
- func IsValidForwardingType(input string) bool
- func LogString(h http.Header) string
- func MakeResultsHeader(engine, status, ffstatus string, fetched timeseries.ExtentList) string
- func Merge(dst, src http.Header)
- func MergeResultHeaderVals(h1, h2 string) string
- func SetResultsHeader(headers http.Header, engine, status, ffstatus string, ...)
- func SetVia(r *http.Request, hop *Hop)
- func String(h http.Header) string
- func StripClientHeaders(h http.Header)
- func StripForwardingHeaders(h http.Header)
- func StripMergeHeaders(h http.Header)
- func UpdateHeaders(headers http.Header, updates map[string]string)
- type Hop
- type Hops
- type Lookup
- type ResultHeaderParts
Constants ¶
const ( // NameVia represents the HTTP Header Name of "Via" NameVia = "Via" // NameForwarded reqresents the HTTP Header Name of "Forwarded" NameForwarded = "Forwarded" // NameXForwardedFor represents the HTTP Header Name of "X-Forwarded-For" NameXForwardedFor = "X-Forwarded-For" // NameXForwardedServer represents the HTTP Header Name of "X-Forwarded-Server" NameXForwardedServer = "X-Forwarded-Server" // NameXForwardedHost represents the HTTP Header Name of "X-Forwarded-Host" NameXForwardedHost = "X-Forwarded-Host" // NameXForwardedProto represents the HTTP Header Name of "X-Forwarded-Proto" NameXForwardedProto = "X-Forwarded-Proto" )
const ( // ValueApplicationCSV represents the HTTP Header Value of "application/csv" ValueApplicationCSV = "application/csv" // ValueApplicationJSON represents the HTTP Header Value of "application/json" ValueApplicationJSON = "application/json" // ValueApplicationFlux represents the HTTP Header Value of "application/vnd.flux" ValueApplicationFlux = "application/vnd.flux" // ValueChunked represents the HTTP Header Value of "chunked" ValueChunked = "chunked" // ValueClose represents the HTTP Header Value of "close" ValueClose = "close" // ValueMaxAge represents the HTTP Header Value of "max-age" ValueMaxAge = "max-age" // ValueMultipartFormData represents the HTTP Header Value of "multipart/form-data" ValueMultipartFormData = "multipart/form-data" // ValueMustRevalidate represents the HTTP Header Value of "must-revalidate" ValueMustRevalidate = "must-revalidate" // ValueNoCache represents the HTTP Header Value of "no-cache" ValueNoCache = "no-cache" // ValueNoStore represents the HTTP Header Value of "no-store" ValueNoStore = "no-store" // ValueNoTransform represents the HTTP Header Value of "no-transform" ValueNoTransform = "no-transform" // ValuePrivate represents the HTTP Header Value of "private" ValuePrivate = "private" // ValueProxyRevalidate represents the HTTP Header Value of "proxy-revalidate" ValueProxyRevalidate = "proxy-revalidate" // ValuePublic represents the HTTP Header Value of "public" ValuePublic = "public" ValueSharedMaxAge = "s-maxage" // ValueTextPlain represents the HTTP Header Value of "text/plain" ValueTextPlain = "text/plain" // ValueXFormURLEncoded represents the HTTP Header Value of "application/x-www-form-urlencoded" ValueXFormURLEncoded = "application/x-www-form-urlencoded" // ValueMultipartByteRanges represents the HTTP Header prefix for a Multipart Byte Range response ValueMultipartByteRanges = "multipart/byteranges; boundary=" // NameAccept represents the HTTP Header Name of "Accept" NameAccept = "Accept" // NameCacheControl represents the HTTP Header Name of "Cache-Control" NameCacheControl = "Cache-Control" // NameAllowOrigin represents the HTTP Header Name of "Access-Control-Allow-Origin" NameAllowOrigin = "Access-Control-Allow-Origin" // NameConnection represents the HTTP Header Name of "Connection" NameConnection = "Connection" // NameContentType represents the HTTP Header Name of "Content-Type" NameContentType = "Content-Type" // NameContentEncoding represents the HTTP Header Name of "Content-Encoding" NameContentEncoding = "Content-Encoding" // NameContentLength represents the HTTP Header Name of "Content-Length" NameContentLength = "Content-Length" // NameAuthorization represents the HTTP Header Name of "Authorization" NameAuthorization = "Authorization" // NameContentRange represents the HTTP Header Name of "Content-Range" NameContentRange = "Content-Range" // NameTricksterResult represents the HTTP Header Name of "X-Trickster-Result" NameTricksterResult = "X-Trickster-Result" // NameAcceptEncoding represents the HTTP Header Name of "Accept-Encoding" NameAcceptEncoding = "Accept-Encoding" // NameSetCookie represents the HTTP Header Name of "Set-Cookie" NameSetCookie = "Set-Cookie" // NameRange represents the HTTP Header Name of "Range" NameRange = "Range" // NameTransferEncoding represents the HTTP Header Name of "Transfer-Encoding" NameTransferEncoding = "Transfer-Encoding" // NameIfModifiedSince represents the HTTP Header Name of "If-Modified-Since" NameIfModifiedSince = "If-Modified-Since" // NameIfUnmodifiedSince represents the HTTP Header Name of "If-Unodified-Since" NameIfUnmodifiedSince = "If-Unmodified-Since" // NameIfNoneMatch represents the HTTP Header Name of "If-None-Match" NameIfNoneMatch = "If-None-Match" // NameIfMatch represents the HTTP Header Name of "If-Match" NameIfMatch = "If-Match" // NameDate represents the HTTP Header Name of "date" NameDate = "Date" // NamePragma represents the HTTP Header Name of "pragma" NamePragma = "Pragma" // NameProxyAuthenticate represents the HTTP Header Name of "Proxy-Authenticate" NameProxyAuthenticate = "Proxy-Authenticate" // NameProxyAuthorization represents the HTTP Header Name of "Proxy-Authorization" NameProxyAuthorization = "Proxy-Authorization" // NameProxyConnection represents the HTTP Header Name of "Proxy-Connection" NameProxyConnection = "Proxy-Connection" // NameKeepAlive represents the HTTP Header Name of "Keep-Alive" NameKeepAlive = "Keep-Alive" // NameLastModified represents the HTTP Header Name of "last-modified" NameLastModified = "Last-Modified" // NameExpires represents the HTTP Header Name of "expires" NameExpires = "Expires" // NameETag represents the HTTP Header Name of "etag" NameETag = "Etag" // NameLocation represents the HTTP Header Name of "location" NameLocation = "Location" // NameTe represents the HTTP Header Name of "TE" NameTe = "Te" // NameTrailer represents the HTTP Header Name of "Trailer" NameTrailer = "Trailer" // NameUpgrade represents the HTTP Header Name of "Upgrade" NameUpgrade = "Upgrade" // NameTrkHCStatus represents the HTTP Header Name of "Trk-HC-Status" NameTrkHCStatus = "Trk-HC-Status" // NameTrkHCDetail represents the HTTP Header Name of "Trk-HC-Detail" NameTrkHCDetail = "Trk-HC-Detail" )
Variables ¶
var ForwardingHeaders = []string{ NameXForwardedFor, NameXForwardedHost, NameXForwardedProto, NameXForwardedServer, NameForwarded, NameVia, }
ForwardingHeaders defines a list of headers that Proxies use to identify themselves in a request
var HopHeaders = []string{ NameAcceptEncoding, NameConnection, NameProxyConnection, NameKeepAlive, NameProxyAuthenticate, NameProxyAuthorization, NameTe, NameTrailer, NameTransferEncoding, NameUpgrade, NameAcceptEncoding, }
HopHeaders defines a list of headers that Proxies should not pass through
var MergeRemoveHeaders = []string{ NameLastModified, NameDate, NameContentLength, NameContentType, NameTransferEncoding, }
MergeRemoveHeaders defines a list of headers that should be removed when Merging time series results
Functions ¶
func AddForwarded ¶
AddForwarded sets or appends to the standard Forwarded header to the provided request
func AddForwardedAndX ¶
AddForwardedAndX sets or appends to the to the "X-Forwarded-*" headers headers, and to the standard Forwarded header to the provided request
func AddForwardingHeaders ¶
AddForwardingHeaders sets or appends to the forwarding headers to the provided request
func AddResponseHeaders ¶
AddResponseHeaders injects standard Trickster headers into downstream HTTP responses
func AddXForwarded ¶
AddXForwarded sets or appends to the "X-Forwarded-*" headers to the provided request
func ExtractHeader ¶
ExtractHeader returns the value for the provided header name, and a boolean indicating if the header was present
func HideAuthorizationCredentials ¶
func HideAuthorizationCredentials(headers Lookup)
HideAuthorizationCredentials replaces any sensitive HTTP header values with 5 asterisks sensitive headers are defined in the sensitiveCredentials map
func IsValidForwardingType ¶
IsValidForwardingType returns true if the input is a valid Forwarding Type name Valid names comprise the keys of the forwardingFuncs map
func LogString ¶
LogString returns a compact string representation of the headers suitable for use with logging
func MakeResultsHeader ¶
func MakeResultsHeader(engine, status, ffstatus string, fetched timeseries.ExtentList) string
MakeResultsHeader returns a header value summarizing Trickster's handling of the HTTP request
func Merge ¶
Merge merges the source http.Header map into destination map. If a key exists in both maps, the source value wins. If the destination map is nil, the source map will not be merged
func MergeResultHeaderVals ¶
MergeResultHeaderVals merges 2 Trickster Result Headers
func SetResultsHeader ¶
func SetResultsHeader(headers http.Header, engine, status, ffstatus string, fetched timeseries.ExtentList)
SetResultsHeader adds a response header summarizing Trickster's handling of the HTTP request
func String ¶
String returns the string representation of the headers as if they were transmitted over the wire (Header1: value1\nHeader2: value2\n\n)
func StripClientHeaders ¶
StripClientHeaders strips certain headers from the HTTP request to facililate acceleration
func StripForwardingHeaders ¶
StripForwardingHeaders strips certain headers from the HTTP request to facililate acceleration
func StripMergeHeaders ¶
StripMergeHeaders strips certain headers from the HTTP request to facililate acceleration when merging HTTP responses from multiple origins
Types ¶
type Hop ¶
type Hop struct { // RemoteAddr is the client address for which the request is being forwarded. RemoteAddr string // Host header as received by the proxy Host string // Scheme is the protocol scheme requested of the proxy Scheme string // Server is an identifier for the server running the Trickster process Server string // protocol indicates the HTTP protocol Version in proper format (.eg., "HTTP/1.1") // requested by the client Protocol string // Hops is a list of previous X-Forwarded-For or Forwarded headers to which we can append our hop Hops Hops // Via is the previous Via header, we will append ours to it. Via string }
Hop describes a collection of data about the forwarded request to be used in Via, Forwarded and X-Forwarded-* headers
func HopsFromRequest ¶
HopsFromRequest extracts a Hop reference that includes a list of any previous hops
type Hops ¶
type Hops []*Hop
Hops defines a list of Hop References
func HopsFromHeader ¶
HopsFromHeader extracts a hop from the header
type Lookup ¶
Lookup represents a simple lookup for internal header manipulation
type ResultHeaderParts ¶
type ResultHeaderParts struct { Engine string Status string Fetched timeseries.ExtentList FastForwardStatus string }
ResultHeaderParts defines the components for building the Trickster Result Header
func (ResultHeaderParts) String ¶
func (p ResultHeaderParts) String() string