📋 常量
HTTP 方法从 net/http 复制而来
const (MethodGet = "GET" // RFC 7231, 4.3.1MethodHead = "HEAD" // RFC 7231, 4.3.2MethodPost = "POST" // RFC 7231, 4.3.3MethodPut = "PUT" // RFC 7231, 4.3.4MethodPatch = "PATCH" // RFC 5789MethodDelete = "DELETE" // RFC 7231, 4.3.5MethodConnect = "CONNECT" // RFC 7231, 4.3.6MethodOptions = "OPTIONS" // RFC 7231, 4.3.7MethodTrace = "TRACE" // RFC 7231, 4.3.8methodUse = "USE")
常用 MIME 类型
const (MIMETextXML = "text/xml"MIMETextHTML = "text/html"MIMETextPlain = "text/plain"MIMEApplicationXML = "application/xml"MIMEApplicationJSON = "application/json"MIMEApplicationJavaScript = "application/javascript"MIMEApplicationForm = "application/x-www-form-urlencoded"MIMEOctetStream = "application/octet-stream"MIMEMultipartForm = "multipart/form-data"MIMETextXMLCharsetUTF8 = "text/xml; charset=utf-8"MIMETextHTMLCharsetUTF8 = "text/html; charset=utf-8"MIMETextPlainCharsetUTF8 = "text/plain; charset=utf-8"MIMEApplicationXMLCharsetUTF8 = "application/xml; charset=utf-8"MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8"MIMEApplicationJavaScriptCharsetUTF8 = "application/javascript; charset=utf-8")
HTTP 状态码从 net/http 复制而来
const (StatusContinue = 100 // RFC 7231, 6.2.1StatusSwitchingProtocols = 101 // RFC 7231, 6.2.2StatusProcessing = 102 // RFC 2518, 10.1StatusEarlyHints = 103 // RFC 8297StatusOK = 200 // RFC 7231, 6.3.1StatusCreated = 201 // RFC 7231, 6.3.2StatusAccepted = 202 // RFC 7231, 6.3.3StatusNonAuthoritativeInformation = 203 // RFC 7231, 6.3.4StatusNoContent = 204 // RFC 7231, 6.3.5StatusResetContent = 205 // RFC 7231, 6.3.6StatusPartialContent = 206 // RFC 7233, 4.1StatusMultiStatus = 207 // RFC 4918, 11.1StatusAlreadyReported = 208 // RFC 5842, 7.1StatusIMUsed = 226 // RFC 3229, 10.4.1StatusMultipleChoices = 300 // RFC 7231, 6.4.1StatusMovedPermanently = 301 // RFC 7231, 6.4.2StatusFound = 302 // RFC 7231, 6.4.3StatusSeeOther = 303 // RFC 7231, 6.4.4StatusNotModified = 304 // RFC 7232, 4.1StatusUseProxy = 305 // RFC 7231, 6.4.5StatusTemporaryRedirect = 307 // RFC 7231, 6.4.7StatusPermanentRedirect = 308 // RFC 7538, 3StatusBadRequest = 400 // RFC 7231, 6.5.1StatusUnauthorized = 401 // RFC 7235, 3.1StatusPaymentRequired = 402 // RFC 7231, 6.5.2StatusForbidden = 403 // RFC 7231, 6.5.3StatusNotFound = 404 // RFC 7231, 6.5.4StatusMethodNotAllowed = 405 // RFC 7231, 6.5.5StatusNotAcceptable = 406 // RFC 7231, 6.5.6StatusProxyAuthRequired = 407 // RFC 7235, 3.2StatusRequestTimeout = 408 // RFC 7231, 6.5.7StatusConflict = 409 // RFC 7231, 6.5.8StatusGone = 410 // RFC 7231, 6.5.9StatusLengthRequired = 411 // RFC 7231, 6.5.10StatusPreconditionFailed = 412 // RFC 7232, 4.2StatusRequestEntityTooLarge = 413 // RFC 7231, 6.5.11StatusRequestURITooLong = 414 // RFC 7231, 6.5.12StatusUnsupportedMediaType = 415 // RFC 7231, 6.5.13StatusRequestedRangeNotSatisfiable = 416 // RFC 7233, 4.4StatusExpectationFailed = 417 // RFC 7231, 6.5.14StatusTeapot = 418 // RFC 7168, 2.3.3StatusMisdirectedRequest = 421 // RFC 7540, 9.1.2StatusUnprocessableEntity = 422 // RFC 4918, 11.2StatusLocked = 423 // RFC 4918, 11.3StatusFailedDependency = 424 // RFC 4918, 11.4StatusTooEarly = 425 // RFC 8470, 5.2.StatusUpgradeRequired = 426 // RFC 7231, 6.5.15StatusPreconditionRequired = 428 // RFC 6585, 3StatusTooManyRequests = 429 // RFC 6585, 4StatusRequestHeaderFieldsTooLarge = 431 // RFC 6585, 5StatusUnavailableForLegalReasons = 451 // RFC 7725, 3StatusInternalServerError = 500 // RFC 7231, 6.6.1StatusNotImplemented = 501 // RFC 7231, 6.6.2StatusBadGateway = 502 // RFC 7231, 6.6.3StatusServiceUnavailable = 503 // RFC 7231, 6.6.4StatusGatewayTimeout = 504 // RFC 7231, 6.6.5StatusHTTPVersionNotSupported = 505 // RFC 7231, 6.6.6StatusVariantAlsoNegotiates = 506 // RFC 2295, 8.1StatusInsufficientStorage = 507 // RFC 4918, 11.5StatusLoopDetected = 508 // RFC 5842, 7.2StatusNotExtended = 510 // RFC 2774, 7StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6)
错误类型
var (ErrBadRequest = NewError(StatusBadRequest) // RFC 7231, 6.5.1ErrUnauthorized = NewError(StatusUnauthorized) // RFC 7235, 3.1ErrPaymentRequired = NewError(StatusPaymentRequired) // RFC 7231, 6.5.2ErrForbidden = NewError(StatusForbidden) // RFC 7231, 6.5.3ErrNotFound = NewError(StatusNotFound) // RFC 7231, 6.5.4ErrMethodNotAllowed = NewError(StatusMethodNotAllowed) // RFC 7231, 6.5.5ErrNotAcceptable = NewError(StatusNotAcceptable) // RFC 7231, 6.5.6ErrProxyAuthRequired = NewError(StatusProxyAuthRequired) // RFC 7235, 3.2ErrRequestTimeout = NewError(StatusRequestTimeout) // RFC 7231, 6.5.7ErrConflict = NewError(StatusConflict) // RFC 7231, 6.5.8ErrGone = NewError(StatusGone) // RFC 7231, 6.5.9ErrLengthRequired = NewError(StatusLengthRequired) // RFC 7231, 6.5.10ErrPreconditionFailed = NewError(StatusPreconditionFailed) // RFC 7232, 4.2ErrRequestEntityTooLarge = NewError(StatusRequestEntityTooLarge) // RFC 7231, 6.5.11ErrRequestURITooLong = NewError(StatusRequestURITooLong) // RFC 7231, 6.5.12ErrUnsupportedMediaType = NewError(StatusUnsupportedMediaType) // RFC 7231, 6.5.13ErrRequestedRangeNotSatisfiable = NewError(StatusRequestedRangeNotSatisfiable) // RFC 7233, 4.4ErrExpectationFailed = NewError(StatusExpectationFailed) // RFC 7231, 6.5.14ErrTeapot = NewError(StatusTeapot) // RFC 7168, 2.3.3ErrMisdirectedRequest = NewError(StatusMisdirectedRequest) // RFC 7540, 9.1.2ErrUnprocessableEntity = NewError(StatusUnprocessableEntity) // RFC 4918, 11.2ErrLocked = NewError(StatusLocked) // RFC 4918, 11.3ErrFailedDependency = NewError(StatusFailedDependency) // RFC 4918, 11.4ErrTooEarly = NewError(StatusTooEarly) // RFC 8470, 5.2.ErrUpgradeRequired = NewError(StatusUpgradeRequired) // RFC 7231, 6.5.15ErrPreconditionRequired = NewError(StatusPreconditionRequired) // RFC 6585, 3ErrTooManyRequests = NewError(StatusTooManyRequests) // RFC 6585, 4ErrRequestHeaderFieldsTooLarge = NewError(StatusRequestHeaderFieldsTooLarge) // RFC 6585, 5ErrUnavailableForLegalReasons = NewError(StatusUnavailableForLegalReasons) // RFC 7725, 3ErrInternalServerError = NewError(StatusInternalServerError) // RFC 7231, 6.6.1ErrNotImplemented = NewError(StatusNotImplemented) // RFC 7231, 6.6.2ErrBadGateway = NewError(StatusBadGateway) // RFC 7231, 6.6.3ErrServiceUnavailable = NewError(StatusServiceUnavailable) // RFC 7231, 6.6.4ErrGatewayTimeout = NewError(StatusGatewayTimeout) // RFC 7231, 6.6.5ErrHTTPVersionNotSupported = NewError(StatusHTTPVersionNotSupported) // RFC 7231, 6.6.6ErrVariantAlsoNegotiates = NewError(StatusVariantAlsoNegotiates) // RFC 2295, 8.1ErrInsufficientStorage = NewError(StatusInsufficientStorage) // RFC 4918, 11.5ErrLoopDetected = NewError(StatusLoopDetected) // RFC 5842, 7.2ErrNotExtended = NewError(StatusNotExtended) // RFC 2774, 7ErrNetworkAuthenticationRequired = NewError(StatusNetworkAuthenticationRequired) // RFC 6585, 6)
HTTP 头信息从 net/http 复制而来
const (HeaderAuthorization = "Authorization"HeaderProxyAuthenticate = "Proxy-Authenticate"HeaderProxyAuthorization = "Proxy-Authorization"HeaderWWWAuthenticate = "WWW-Authenticate"HeaderAge = "Age"HeaderCacheControl = "Cache-Control"HeaderClearSiteData = "Clear-Site-Data"HeaderExpires = "Expires"HeaderPragma = "Pragma"HeaderWarning = "Warning"HeaderAcceptCH = "Accept-CH"HeaderAcceptCHLifetime = "Accept-CH-Lifetime"HeaderContentDPR = "Content-DPR"HeaderDPR = "DPR"HeaderEarlyData = "Early-Data"HeaderSaveData = "Save-Data"HeaderViewportWidth = "Viewport-Width"HeaderWidth = "Width"HeaderETag = "ETag"HeaderIfMatch = "If-Match"HeaderIfModifiedSince = "If-Modified-Since"HeaderIfNoneMatch = "If-None-Match"HeaderIfUnmodifiedSince = "If-Unmodified-Since"HeaderLastModified = "Last-Modified"HeaderVary = "Vary"HeaderConnection = "Connection"HeaderKeepAlive = "Keep-Alive"HeaderAccept = "Accept"HeaderAcceptCharset = "Accept-Charset"HeaderAcceptEncoding = "Accept-Encoding"HeaderAcceptLanguage = "Accept-Language"HeaderCookie = "Cookie"HeaderExpect = "Expect"HeaderMaxForwards = "Max-Forwards"HeaderSetCookie = "Set-Cookie"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"HeaderOrigin = "Origin"HeaderTimingAllowOrigin = "Timing-Allow-Origin"HeaderXPermittedCrossDomainPolicies = "X-Permitted-Cross-Domain-Policies"HeaderDNT = "DNT"HeaderTk = "Tk"HeaderContentDisposition = "Content-Disposition"HeaderContentEncoding = "Content-Encoding"HeaderContentLanguage = "Content-Language"HeaderContentLength = "Content-Length"HeaderContentLocation = "Content-Location"HeaderContentType = "Content-Type"HeaderForwarded = "Forwarded"HeaderVia = "Via"HeaderXForwardedFor = "X-Forwarded-For"HeaderXForwardedHost = "X-Forwarded-Host"HeaderXForwardedProto = "X-Forwarded-Proto"HeaderXForwardedProtocol = "X-Forwarded-Protocol"HeaderXForwardedSsl = "X-Forwarded-Ssl"HeaderXUrlScheme = "X-Url-Scheme"HeaderLocation = "Location"HeaderFrom = "From"HeaderHost = "Host"HeaderReferer = "Referer"HeaderReferrerPolicy = "Referrer-Policy"HeaderUserAgent = "User-Agent"HeaderAllow = "Allow"HeaderServer = "Server"HeaderAcceptRanges = "Accept-Ranges"HeaderContentRange = "Content-Range"HeaderIfRange = "If-Range"HeaderRange = "Range"HeaderContentSecurityPolicy = "Content-Security-Policy"HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only"HeaderCrossOriginResourcePolicy = "Cross-Origin-Resource-Policy"HeaderExpectCT = "Expect-CT"HeaderFeaturePolicy = "Feature-Policy"HeaderPublicKeyPins = "Public-Key-Pins"HeaderPublicKeyPinsReportOnly = "Public-Key-Pins-Report-Only"HeaderStrictTransportSecurity = "Strict-Transport-Security"HeaderUpgradeInsecureRequests = "Upgrade-Insecure-Requests"HeaderXContentTypeOptions = "X-Content-Type-Options"HeaderXDownloadOptions = "X-Download-Options"HeaderXFrameOptions = "X-Frame-Options"HeaderXPoweredBy = "X-Powered-By"HeaderXXSSProtection = "X-XSS-Protection"HeaderLastEventID = "Last-Event-ID"HeaderNEL = "NEL"HeaderPingFrom = "Ping-From"HeaderPingTo = "Ping-To"HeaderReportTo = "Report-To"HeaderTE = "TE"HeaderTrailer = "Trailer"HeaderTransferEncoding = "Transfer-Encoding"HeaderSecWebSocketAccept = "Sec-WebSocket-Accept"HeaderSecWebSocketExtensions = "Sec-WebSocket-Extensions"HeaderSecWebSocketKey = "Sec-WebSocket-Key"HeaderSecWebSocketProtocol = "Sec-WebSocket-Protocol"HeaderSecWebSocketVersion = "Sec-WebSocket-Version"HeaderAcceptPatch = "Accept-Patch"HeaderAcceptPushPolicy = "Accept-Push-Policy"HeaderAcceptSignature = "Accept-Signature"HeaderAltSvc = "Alt-Svc"HeaderDate = "Date"HeaderIndex = "Index"HeaderLargeAllocation = "Large-Allocation"HeaderLink = "Link"HeaderPushPolicy = "Push-Policy"HeaderRetryAfter = "Retry-After"HeaderServerTiming = "Server-Timing"HeaderSignature = "Signature"HeaderSignedHeaders = "Signed-Headers"HeaderSourceMap = "SourceMap"HeaderUpgrade = "Upgrade"HeaderXDNSPrefetchControl = "X-DNS-Prefetch-Control"HeaderXPingback = "X-Pingback"HeaderXRequestID = "X-Request-ID"HeaderXRequestedWith = "X-Requested-With"HeaderXRobotsTag = "X-Robots-Tag"HeaderXUACompatible = "X-UA-Compatible")
