httpcommon
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- Variables
- func CachedCanonicalHeader(v string) (string, bool)
- func CanonicalHeader(v string) string
- func IsRequestGzip(method string, header map[string][]string, disableCompression bool) bool
- func LowerHeader(v string) (lower string, ascii bool)
- type EncodeHeadersParam
- type EncodeHeadersResult
- type Request
- type ServerRequestParam
- type ServerRequestResult
Constants¶
This section is empty.
Variables¶
var (ErrRequestHeaderListSize =errors.New("request header list larger than peer's advertised limit"))Functions¶
funcCachedCanonicalHeader¶
CachedCanonicalHeader returns the canonical form of a well-known header name.
funcCanonicalHeader¶
CanonicalHeader canonicalizes a header name. (For example, "host" becomes "Host".)
funcIsRequestGzip¶
IsRequestGzip reports whether we should add an Accept-Encoding: gzip headerfor a request.
funcLowerHeader¶
LowerHeader returns the lowercase form of a header name,used on the wire for HTTP/2 and HTTP/3 requests.
Types¶
typeEncodeHeadersParam¶
type EncodeHeadersParam struct {RequestRequest// AddGzipHeader indicates that an "accept-encoding: gzip" header should be// added to the request.AddGzipHeaderbool// PeerMaxHeaderListSize, when non-zero, is the peer's MAX_HEADER_LIST_SIZE setting.PeerMaxHeaderListSizeuint64// DefaultUserAgent is the User-Agent header to send when the request// neither contains a User-Agent nor disables it.DefaultUserAgentstring}EncodeHeadersParam is parameters to EncodeHeaders.
typeEncodeHeadersResult¶
EncodeHeadersParam is the result of EncodeHeaders.
funcEncodeHeaders¶
func EncodeHeaders(ctxcontext.Context, paramEncodeHeadersParam, headerf func(name, valuestring)) (resEncodeHeadersResult, _error)
EncodeHeaders constructs request headers common to HTTP/2 and HTTP/3.It validates a request and calls headerf with each pseudo-header and headerfor the request.The headerf function is called with the validated, canonicalized header name.
typeRequest¶
type Request struct {URL *url.URLMethodstringHoststringHeader map[string][]stringTrailer map[string][]stringActualContentLengthint64// 0 means 0, -1 means unknown}Request is a subset of http.Request.It'd be simpler to pass an *http.Request, of course, but we can't depend on net/httpwithout creating a dependency cycle.
typeServerRequestParam¶
type ServerRequestParam struct {MethodstringScheme, Authority, PathstringProtocolstringHeader map[string][]string}ServerRequestParam is parameters to NewServerRequest.
typeServerRequestResult¶
type ServerRequestResult struct {// Various http.Request fields.URL *url.URLRequestURIstringTrailer map[string][]stringNeedsContinuebool// client provided an "Expect: 100-continue" header// If the request should be rejected, this is a short string suitable for passing// to the http2 package's CountError function.// It might be a bit odd to return errors this way rather than returing an error,// but this ensures we don't forget to include a CountError reason.InvalidReasonstring}ServerRequestResult is the result of NewServerRequest.
funcNewServerRequest¶
func NewServerRequest(rpServerRequestParam)ServerRequestResult