httpx

package
v0.93.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package httpx provides HTTP header names, content types, and other constants for use throughout the framework.

Content-Type constants include (among others):

[MIMETextHTML], [MIMETextPlain], [MIMEApplicationJSON]
[MIMEApplicationProblemJSON], [MIMEApplicationFormURLEncoded]

Header name constants include (among others):

[HeaderContentType], [HeaderAuthorization], [HeaderXRequestId]
[HeaderCacheControl], [HeaderETag], [HeaderLocation]

CORS and Security headers include (among others):

[HeaderAccessControlAllowOrigin]
[HeaderContentSecurityPolicy]
[HeaderStrictTransportSecurity]

See the full list of constants below for complete coverage of headers, content types, authentication schemes, and common header values.

Index

Constants

View Source
const (
	MIMETextHTML                  = "text/html"
	MIMETextHTMLCharset           = "text/html; charset=utf-8"
	MIMETextPlain                 = "text/plain"
	MIMETextPlainCharset          = "text/plain; charset=utf-8"
	MIMETextEventStream           = "text/event-stream"
	MIMETextCSS                   = "text/css"
	MIMETextJavaScript            = "text/javascript"
	MIMEApplicationJSON           = "application/json"
	MIMEApplicationJSONCharset    = "application/json; charset=utf-8"
	MIMEApplicationJavaScript     = "application/javascript"
	MIMEApplicationXML            = "application/xml"
	MIMEApplicationProblemJSON    = "application/problem+json"
	MIMEApplicationFormURLEncoded = "application/x-www-form-urlencoded"
	MIMEApplicationRSSXML         = "application/rss+xml"
	MIMEApplicationAtomXML        = "application/atom+xml"
	MIMEMultipartFormData         = "multipart/form-data"
	MIMETextXML                   = "text/xml"
	MIMEImageSVGXML               = "image/svg+xml"
)
View Source
const (
	HeaderAccept             = "Accept"
	HeaderAcceptCharset      = "Accept-Charset"
	HeaderAcceptEncoding     = "Accept-Encoding"
	HeaderAcceptLanguage     = "Accept-Language"
	HeaderAcceptRanges       = "Accept-Ranges"
	HeaderAuthorization      = "Authorization"
	HeaderCacheControl       = "Cache-Control"
	HeaderConnection         = "Connection"
	HeaderContentLength      = "Content-Length"
	HeaderContentType        = "Content-Type"
	HeaderCookie             = "Cookie"
	HeaderDate               = "Date"
	HeaderExpect             = "Expect"
	HeaderForwarded          = "Forwarded"
	HeaderFrom               = "From"
	HeaderHost               = "Host"
	HeaderIfMatch            = "If-Match"
	HeaderIfModifiedSince    = "If-Modified-Since"
	HeaderIfNoneMatch        = "If-None-Match"
	HeaderIfRange            = "If-Range"
	HeaderIfUnmodifiedSince  = "If-Unmodified-Since"
	HeaderLastEventId        = "Last-Event-Id"
	HeaderMaxForwards        = "Max-Forwards"
	HeaderOrigin             = "Origin"
	HeaderPragma             = "Pragma"
	HeaderProxyAuthorization = "Proxy-Authorization"
	HeaderRange              = "Range"
	HeaderReferer            = "Referer"
	HeaderTE                 = "TE"
	HeaderUserAgent          = "User-Agent"
	HeaderUpgrade            = "Upgrade"
	HeaderVia                = "Via"
	HeaderWarning            = "Warning"
)

Request Headers

View Source
const (
	HeaderAcceptPatch        = "Accept-Patch"
	HeaderAcceptPost         = "Accept-Post"
	HeaderAge                = "Age"
	HeaderAllow              = "Allow"
	HeaderAltSvc             = "Alt-Svc"
	HeaderContentDisposition = "Content-Disposition"
	HeaderContentEncoding    = "Content-Encoding"
	HeaderContentLanguage    = "Content-Language"
	HeaderContentLocation    = "Content-Location"
	HeaderContentRange       = "Content-Range"
	HeaderETag               = "ETag"
	HeaderExpires            = "Expires"
	HeaderIdempotencyKey     = "Idempotency-Key"
	HeaderKeepAlive          = "Keep-Alive"
	HeaderLastModified       = "Last-Modified"
	HeaderLink               = "Link"
	HeaderLocation           = "Location"
	HeaderProxyAuthenticate  = "Proxy-Authenticate"
	HeaderRetryAfter         = "Retry-After"
	HeaderServer             = "Server"
	HeaderSetCookie          = "Set-Cookie"
	HeaderTrailer            = "Trailer"
	HeaderTransferEncoding   = "Transfer-Encoding"
	HeaderVary               = "Vary"
	HeaderWWWAuthenticate    = "WWW-Authenticate"
)

Response Headers

View Source
const (
	HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderAccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	HeaderAccessControlAllowMethods     = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderAccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	HeaderAccessControlMaxAge           = "Access-Control-Max-Age"
	HeaderAccessControlRequestHeaders   = "Access-Control-Request-Headers"
	HeaderAccessControlRequestMethod    = "Access-Control-Request-Method"
)

CORS Headers

View Source
const (
	HeaderContentSecurityPolicy           = "Content-Security-Policy"
	HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only"
	HeaderCrossOriginEmbedderPolicy       = "Cross-Origin-Embedder-Policy"
	HeaderCrossOriginOpenerPolicy         = "Cross-Origin-Opener-Policy"
	HeaderCrossOriginResourcePolicy       = "Cross-Origin-Resource-Policy"
	HeaderFeaturePolicy                   = "Feature-Policy"
	HeaderPermissionsPolicy               = "Permissions-Policy"
	HeaderReferrerPolicy                  = "Referrer-Policy"
	HeaderSecFetchSite                    = "Sec-Fetch-Site"
	HeaderStrictTransportSecurity         = "Strict-Transport-Security"
	HeaderXContentTypeOptions             = "X-Content-Type-Options"
	HeaderXFrameOptions                   = "X-Frame-Options"
	HeaderXXSSProtection                  = "X-XSS-Protection"
)

Security Headers

View Source
const (
	HeaderXAccelExpires       = "X-Accel-Expires"
	HeaderXAPIKey             = "X-API-Key"
	HeaderXCache              = "X-Cache"
	HeaderXCSRFToken          = "X-CSRF-Token"
	HeaderXForwarded          = "X-Forwarded"
	HeaderXForwardedFor       = "X-Forwarded-For"
	HeaderXForwardedHost      = "X-Forwarded-Host"
	HeaderXForwardedProto     = "X-Forwarded-Proto"
	HeaderXForwardedProtocol  = "X-Forwarded-Protocol"
	HeaderXForwardedSsl       = "X-Forwarded-Ssl"
	HeaderXIdempotencyReplay  = "X-Idempotency-Replay"
	HeaderXPoweredBy          = "X-Powered-By"
	HeaderXRateLimitLimit     = "X-RateLimit-Limit"
	HeaderXRateLimitRemaining = "X-RateLimit-Remaining"
	HeaderXRateLimitReset     = "X-RateLimit-Reset"
	HeaderXRateLimitWindow    = "X-RateLimit-Window"
	HeaderXRealIP             = "X-Real-IP"
	HeaderXRequestId          = "X-Request-Id"
	HeaderXRequestedWith      = "X-Requested-With"
	HeaderXTimestamp          = "X-Timestamp"
	HeaderXTotal              = "X-Total"
	HeaderXTotalPages         = "X-Total-Pages"
	HeaderXPage               = "X-Page"
	HeaderXPerPage            = "X-Per-Page"
	HeaderXPrevPage           = "X-Prev-Page"
	HeaderXNextPage           = "X-Next-Page"
)

Custom/Extension Headers

View Source
const (
	UpgradeWebSocket             = "websocket"
	HeaderSecWebSocketKey        = "Sec-WebSocket-Key"
	HeaderSecWebSocketAccept     = "Sec-WebSocket-Accept"
	HeaderSecWebSocketVersion    = "Sec-WebSocket-Version"
	HeaderSecWebSocketProtocol   = "Sec-WebSocket-Protocol"
	HeaderSecWebSocketExtensions = "Sec-WebSocket-Extensions"
)

WebSocket Headers

View Source
const (
	AuthSchemeBasic  = "Basic"
	AuthSchemeBearer = "Bearer"
	AuthSchemeDigest = "Digest"
	AuthSchemeOAuth  = "OAuth"
)

Authentication Schemes

View Source
const (
	ConnectionClose     = "close"
	ConnectionKeepAlive = "keep-alive"
	ConnectionUpgrade   = "Upgrade"

	CacheControlNoCache        = "no-cache"
	CacheControlNoStore        = "no-store"
	CacheControlNoTransform    = "no-transform"
	CacheControlMaxAge         = "max-age"
	CacheControlMustRevalidate = "must-revalidate"
	CacheControlPrivate        = "private"
	CacheControlPublic         = "public"

	ContentEncodingGzip    = "gzip"
	ContentEncodingDeflate = "deflate"
	ContentEncodingBrotli  = "br"
	ContentEncodingZstd    = "zstd"

	TransferEncodingChunked = "chunked"

	XCacheHit  = "HIT"
	XCacheMiss = "MISS"
)

Common Header Values

View Source
const (
	QueryXHMACAlgorithm     = "X-HMAC-Algorithm"
	QueryXHMACCredential    = "X-HMAC-Credential"
	QueryXHMACSignedHeaders = "X-HMAC-SignedHeaders"
	QueryXHMACSignature     = "X-HMAC-Signature"
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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