github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/http/const.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package http
     4  
     5  /*
     6  				********************PAY ATTENTION:*******************
     7  	We believe HTTP version 2 and above are new protocol not new version of HTTP!!
     8  	So we don't support HTTP2 and HTTP3 specs in this package!!
     9  */
    10  
    11  const (
    12  	// PacketLen is minimum Packet length of HTTP Packet.
    13  	PacketLen = 64
    14  
    15  	// MaxHTTPHeaderSize is max HTTP header size.
    16  	MaxHTTPHeaderSize = 8192
    17  
    18  	// TimeFormat is the time format to use when generating times in HTTP
    19  	// headers. It is like time.RFC1123 but hard-codes GMT as the time
    20  	// zone. The time being formatted must be in UTC for Format to
    21  	// generate the correct format.
    22  	TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
    23  )
    24  
    25  // Some default values
    26  const (
    27  	DefaultUserAgent = "Achaemenid-Client"
    28  	DefaultServer    = "Achaemenid"
    29  
    30  	SP             byte   = ' '  // <US-ASCII SP, space (32)>
    31  	HT             byte   = '	'  // <US-ASCII HT, horizontal-tab (9)>
    32  	CR             byte   = '\r' // <US-ASCII CR, carriage return (13)>
    33  	LF             byte   = '\n' // <US-ASCII LF, linefeed (10)>
    34  	Colon          byte   = ':'
    35  	NumberSign     byte   = '#'
    36  	Comma          byte   = ','
    37  	Question       byte   = '?'
    38  	Slash          byte   = '/'
    39  	Asterisk       byte   = '*'
    40  	CRLF           string = "\r\n"
    41  	ColonSpace     string = ": "
    42  	SemiColonSpace string = "; "
    43  )
    44  
    45  // Standard HTTP versions
    46  const (
    47  	versionMaxLength = 9 // plus one for ' ' or '\r' character after method name.
    48  
    49  	VersionHTTP1  = "HTTP/1.0"
    50  	VersionHTTP11 = "HTTP/1.1"
    51  	VersionHTTP2  = "HTTP/2.0"
    52  	VersionHTTP3  = "HTTP/3.0"
    53  )
    54  
    55  // Standard HTTP methods
    56  // https://tools.ietf.org/html/rfc7231#section-4
    57  const (
    58  	methodMaxLength = 8 // plus one for ' ' character after method name.
    59  
    60  	MethodGET     = "GET"
    61  	MethodPOST    = "POST"
    62  	MethodHEAD    = "HEAD"
    63  	MethodPUT     = "PUT"
    64  	MethodDELETE  = "DELETE"
    65  	MethodOPTIONS = "OPTIONS"
    66  	MethodCONNECT = "CONNECT"
    67  	MethodTRACE   = "TRACE"
    68  	MethodPATCH   = "PATCH" // https://tools.ietf.org/html/rfc5789#section-2
    69  )
    70  
    71  // Standard HTTP header keys
    72  // https://www.iana.org/assignments/message-headers/message-headers.xhtml
    73  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
    74  const (
    75  	// Request context
    76  	HeaderKeyFrom           = "From"
    77  	HeaderKeyHost           = "Host"
    78  	HeaderKeyReferer        = "Referer"
    79  	HeaderKeyReferrerPolicy = "Referrer-Policy"
    80  	HeaderKeyUserAgent      = "User-Agent"
    81  
    82  	// Response context
    83  	HeaderKeyAllow   = "Allow"
    84  	HeaderKeyServer  = "Server"
    85  	HeaderKeyErrorID = "Error-ID"
    86  
    87  	// Authentication
    88  	HeaderKeyAuthorization      = "Authorization"
    89  	HeaderKeyProxyAuthorization = "Proxy-Authorization"
    90  	HeaderKeyProxyAuthenticate  = "Proxy-Authenticate" // res
    91  	HeaderKeyWWWAuthenticate    = "WWW-Authenticate"   // res
    92  
    93  	// Caching
    94  	HeaderKeyAge           = "Age"           // res
    95  	HeaderKeyCacheControl  = "Cache-Control" // req & res
    96  	HeaderKeyClearSiteData = "Clear-Site-Data"
    97  	HeaderKeyExpires       = "Expires" // res
    98  	HeaderKeyPragma        = "Pragma"  // req & res
    99  	HeaderKeyWarning       = "Warning" // req & res
   100  	HeaderKeyVary          = "Vary"    // res
   101  
   102  	// Conditionals
   103  	HeaderKeyETag              = "ETag" // res
   104  	HeaderKeyIfMatch           = "If-Match"
   105  	HeaderKeyIfNoneMatch       = "If-None-Match"
   106  	HeaderKeyIfModifiedSince   = "If-Modified-Since"
   107  	HeaderKeyIfUnmodifiedSince = "If-Unmodified-Since"
   108  	HeaderKeyLastModified      = "Last-Modified" // res
   109  
   110  	// Range requests
   111  	HeaderKeyAcceptRanges = "Accept-Ranges" // res
   112  	HeaderKeyContentRange = "Content-Range" // res
   113  	HeaderKeyIfRange      = "If-Range"
   114  	HeaderKeyRange        = "Range"
   115  
   116  	// Connection management
   117  	HeaderKeyConnection = "Connection" // req & res
   118  	HeaderKeyKeepAlive  = "Keep-Alive"
   119  	HeaderKeyUpgrade    = "Upgrade"
   120  
   121  	// CORS
   122  	HeaderKeyAccessControlAllowOrigin      = "Access-Control-Allow-Origin"      // res
   123  	HeaderKeyAccessControlAllowMethods     = "Access-Control-Allow-Methods"     // res
   124  	HeaderKeyAccessControlAllowCredentials = "Access-Control-Allow-Credentials" // res
   125  	HeaderKeyAccessControlAllowHeaders     = "Access-Control-Allow-Headers"     // res
   126  	HeaderKeyAccessControlExposeHeaders    = "Access-Control-Expose-Headers"    // res
   127  	HeaderKeyAccessControlMaxAge           = "Access-Control-Max-Age"           // res
   128  	HeaderKeyAccessControlRequestHeaders   = "Access-Control-Request-Headers"   // res
   129  	HeaderKeyAccessControlRequestMethod    = "Access-Control-Request-Method"    // res
   130  	HeaderKeyOrigin                        = "Origin"
   131  	HeaderKeyTimingAllowOrigin             = "Timing-Allow-Origin"
   132  	HeaderKeyXPermittedCrossDomainPolicies = "X-Permitted-Cross-Domain-Policies"
   133  
   134  	// Content negotiation
   135  	HeaderKeyAcceptContent  = "Accept"
   136  	HeaderKeyAcceptCharset  = "Accept-Charset" // deprecated
   137  	HeaderKeyAcceptEncoding = "Accept-Encoding"
   138  	HeaderKeyAcceptLanguage = "Accept-Language"
   139  	HeaderKeyAcceptDatetime = "Accept-Datetime"
   140  	HeaderKeyAcceptPatch    = "Accept-Patch" // res
   141  
   142  	// Message body information
   143  	HeaderKeyContentLength      = "Content-Length"      // req & res
   144  	HeaderKeyContentMD5         = "Content-MD5"         // req & res
   145  	HeaderKeyContentType        = "Content-Type"        // req & res
   146  	HeaderKeyContentDisposition = "Content-Disposition" // res
   147  	HeaderKeyContentEncoding    = "Content-Encoding"    // res
   148  	HeaderKeyContentLanguage    = "Content-Language"    // res
   149  	HeaderKeyContentLocation    = "Content-Location"    // res
   150  	HeaderKeyTransferEncoding   = "Transfer-Encoding"   // res
   151  
   152  	// Not ordered
   153  	HeaderKeyCookie                  = "Cookie"
   154  	HeaderKeySetCookie               = "Set-Cookie" // res
   155  	HeaderKeyDate                    = "Date"       // req & res
   156  	HeaderKeyVia                     = "Via"
   157  	HeaderKeyExpect                  = "Expect"
   158  	HeaderKeyForwarded               = "Forwarded"
   159  	HeaderKeyMaxForwards             = "Max-Forwards"
   160  	HeaderKeyTE                      = "TE"
   161  	HeaderKeyAltSvc                  = "Alt-Svc"                   // res
   162  	HeaderKeyLink                    = "Link"                      // res
   163  	HeaderKeyLocation                = "Location"                  // res
   164  	HeaderKeyP3P                     = "P3P"                       // res
   165  	HeaderKeyPublicKeyPins           = "Public-Key-Pins"           // res
   166  	HeaderKeyRefresh                 = "Refresh"                   // res
   167  	HeaderKeyRetryAfter              = "Retry-After"               // res
   168  	HeaderKeyStrictTransportSecurity = "Strict-Transport-Security" // res
   169  	HeaderKeyTrailer                 = "Trailer"                   // res
   170  	HeaderKeyTk                      = "Tk"                        // res
   171  	HeaderKeyXFrameOptions           = "X-Frame-Options"           // res
   172  	HeaderKeyNonAuthoritativeReason  = "Non-Authoritative-Reason"  // res
   173  )
   174  
   175  // Standard HTTP header values
   176  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
   177  const (
   178  	// Connection management
   179  	HeaderValueKeepAlive = "Keep-Alive"
   180  	HeaderValueClose     = "Close"
   181  
   182  	// Message body information
   183  	HeaderValueChunked  = "chunked"
   184  	HeaderValueCompress = "compress"
   185  	HeaderValueDeflate  = "deflate"
   186  	HeaderValueGZIP     = "gzip"
   187  )
   188  
   189  // HTTP Status codes
   190  // https://tools.ietf.org/html/rfc7231#section-6
   191  const (
   192  	statusCodeMaxLength = 4 // plus one for ' ' character after method name.
   193  	// Due to RFC(https://datatracker.ietf.org/doc/html/rfc2616#section-6.1.1) can't indicate phrase max length
   194  
   195  	StatusContinue                 uint16 = 100 // RFC 7231, 6.2.1
   196  	StatusContinueCode                    = "100"
   197  	StatusContinuePhrase                  = "Continue"
   198  	StatusSwitchingProtocols       uint16 = 101 // RFC 7231, 6.2.2
   199  	StatusSwitchingProtocolsCode          = "101"
   200  	StatusSwitchingProtocolsPhrase        = "Switching Protocols"
   201  	StatusProcessing               uint16 = 102 // RFC 2518, 10.1
   202  	StatusProcessingCode                  = "102"
   203  	StatusProcessingPhrase                = "Processing"
   204  
   205  	StatusOK                         uint16 = 200 // RFC 7231, 6.3.1
   206  	StatusOKCode                            = "200"
   207  	StatusOKPhrase                          = "OK"
   208  	StatusCreated                    uint16 = 201 // RFC 7231, 6.3.2
   209  	StatusCreatedCode                       = "201"
   210  	StatusCreatedPhrase                     = "Created"
   211  	StatusAccepted                   uint16 = 202 // RFC 7231, 6.3.3
   212  	StatusAcceptedCode                      = "202"
   213  	StatusAcceptedPhrase                    = "Accepted"
   214  	StatusNonAuthoritativeInfo       uint16 = 203 // RFC 7231, 6.3.4
   215  	StatusNonAuthoritativeInfoCode          = "203"
   216  	StatusNonAuthoritativeInfoPhrase        = "Non-Authoritative Information"
   217  	StatusNoContent                  uint16 = 204 // RFC 7231, 6.3.5
   218  	StatusNoContentCode                     = "204"
   219  	StatusNoContentPhrase                   = "No Content"
   220  	StatusResetContent               uint16 = 205 // RFC 7231, 6.3.6
   221  	StatusResetContentCode                  = "205"
   222  	StatusResetContentPhrase                = "Reset Content"
   223  	StatusPartialContent             uint16 = 206 // RFC 7233, 4.1
   224  	StatusPartialContentCode                = "206"
   225  	StatusPartialContentPhrase              = "Partial Content"
   226  	StatusMultiStatus                uint16 = 207 // RFC 4918, 11.1
   227  	StatusMultiStatusCode                   = "207"
   228  	StatusMultiStatusPhrase                 = "Multi-Status"
   229  	StatusAlreadyReported            uint16 = 208 // RFC 5842, 7.1
   230  	StatusAlreadyReportedCode               = "208"
   231  	StatusAlreadyReportedPhrase             = "Already Reported"
   232  	StatusIMUsed                     uint16 = 226 // RFC 3229, 10.4.1
   233  	StatusIMUsedCode                        = "226"
   234  	StatusIMUsedPhrase                      = "IM Used"
   235  
   236  	StatusMultipleChoices         uint16 = 300 // RFC 7231, 6.4.1
   237  	StatusMultipleChoicesCode            = "300"
   238  	StatusMultipleChoicesPhrase          = "Multiple Choices"
   239  	StatusMovedPermanently        uint16 = 301 // RFC 7231, 6.4.2
   240  	StatusMovedPermanentlyCode           = "301"
   241  	StatusMovedPermanentlyPhrase         = "Moved Permanently"
   242  	StatusFound                   uint16 = 302 // RFC 7231, 6.4.3
   243  	StatusFoundCode                      = "302"
   244  	StatusFoundPhrase                    = "Found"
   245  	StatusSeeOther                uint16 = 303 // RFC 7231, 6.4.4
   246  	StatusSeeOtherCode                   = "303"
   247  	StatusSeeOtherPhrase                 = "See Other"
   248  	StatusNotModified             uint16 = 304 // RFC 7232, 4.1
   249  	StatusNotModifiedCode                = "304"
   250  	StatusNotModifiedPhrase              = "Not Modified"
   251  	StatusUseProxy                uint16 = 305 // RFC 7231, 6.4.5
   252  	StatusUseProxyCode                   = "305"
   253  	StatusUseProxyPhrase                 = "Use Proxy"
   254  	StatusSwitchProxy             uint16 = 306 // RFC 7231, 6.4.6 (Unused)
   255  	StatusSwitchProxyCode                = "306"
   256  	StatusSwitchProxyPhrase              = "Switch Proxy"
   257  	StatusTemporaryRedirect       uint16 = 307 // RFC 7231, 6.4.7
   258  	StatusTemporaryRedirectCode          = "307"
   259  	StatusTemporaryRedirectPhrase        = "Temporary Redirect"
   260  	StatusPermanentRedirect       uint16 = 308 // RFC 7538, 3
   261  	StatusPermanentRedirectCode          = "308"
   262  	StatusPermanentRedirectPhrase        = "Permanent Redirect"
   263  
   264  	StatusBadRequest                       uint16 = 400 // RFC 7231, 6.5.1
   265  	StatusBadRequestCode                          = "400"
   266  	StatusBadRequestPhrase                        = "Bad Request"
   267  	StatusUnauthorized                     uint16 = 401 // RFC 7235, 3.1
   268  	StatusUnauthorizedCode                        = "401"
   269  	StatusUnauthorizedPhrase                      = "Unauthorized"
   270  	StatusPaymentRequired                  uint16 = 402 // RFC 7231, 6.5.2
   271  	StatusPaymentRequiredCode                     = "402"
   272  	StatusPaymentRequiredPhrase                   = "Payment Required"
   273  	StatusForbidden                        uint16 = 403 // RFC 7231, 6.5.3
   274  	StatusForbiddenCode                           = "403"
   275  	StatusForbiddenPhrase                         = "Forbidden"
   276  	StatusNotFound                         uint16 = 404 // RFC 7231, 6.5.4
   277  	StatusNotFoundCode                            = "404"
   278  	StatusNotFoundPhrase                          = "Not Found"
   279  	StatusMethodNotAllowed                 uint16 = 405 // RFC 7231, 6.5.5
   280  	StatusMethodNotAllowedCode                    = "405"
   281  	StatusMethodNotAllowedPhrase                  = "Method Not Allowed"
   282  	StatusNotAcceptable                    uint16 = 406 // RFC 7231, 6.5.6
   283  	StatusNotAcceptableCode                       = "406"
   284  	StatusNotAcceptablePhrase                     = "Not Acceptable"
   285  	StatusProxyAuthRequired                uint16 = 407 // RFC 7235, 3.2
   286  	StatusProxyAuthRequiredCode                   = "407"
   287  	StatusProxyAuthRequiredPhrase                 = "Proxy Authentication Required"
   288  	StatusRequestTimeout                   uint16 = 408 // RFC 7231, 6.5.7
   289  	StatusRequestTimeoutCode                      = "408"
   290  	StatusRequestTimeoutPhrase                    = "Request Timeout"
   291  	StatusConflict                         uint16 = 409 // RFC 7231, 6.5.8
   292  	StatusConflictCode                            = "409"
   293  	StatusConflictPhrase                          = "Conflict"
   294  	StatusGone                             uint16 = 410 // RFC 7231, 6.5.9
   295  	StatusGoneCode                                = "410"
   296  	StatusGonePhrase                              = "Gone"
   297  	StatusLengthRequired                   uint16 = 411 // RFC 7231, 6.5.10
   298  	StatusLengthRequiredCode                      = "411"
   299  	StatusLengthRequiredPhrase                    = "Length Required"
   300  	StatusPreconditionFailed               uint16 = 412 // RFC 7232, 4.2
   301  	StatusPreconditionFailedCode                  = "412"
   302  	StatusPreconditionFailedPhrase                = "Precondition Failed"
   303  	StatusPayloadTooLarge                  uint16 = 413 // RFC 7231, 6.5.11
   304  	StatusPayloadTooLargeCode                     = "413"
   305  	StatusPayloadTooLargePhrase                   = "Payload Too Large"
   306  	StatusURITooLong                       uint16 = 414 // RFC 7231, 6.5.12
   307  	StatusURITooLongCode                          = "414"
   308  	StatusURITooLongPhrase                        = "URI Too Long"
   309  	StatusUnsupportedMediaType             uint16 = 415 // RFC 7231, 6.5.13
   310  	StatusUnsupportedMediaTypeCode                = "415"
   311  	StatusUnsupportedMediaTypePhrase              = "Unsupported Media Type"
   312  	StatusRangeNotSatisfiable              uint16 = 416 // RFC 7233, 4.4
   313  	StatusRangeNotSatisfiableCode                 = "416"
   314  	StatusRangeNotSatisfiablePhrase               = "Requested Range Not Satisfiable"
   315  	StatusExpectationFailed                uint16 = 417 // RFC 7231, 6.5.14
   316  	StatusExpectationFailedCode                   = "417"
   317  	StatusExpectationFailedPhrase                 = "Expectation Failed"
   318  	StatusTeapot                           uint16 = 418 // RFC 7168, 2.3.3
   319  	StatusTeapotCode                              = "418"
   320  	StatusTeapotPhrase                            = "I'm a teapot"
   321  	StatusUnprocessableEntity              uint16 = 422 // RFC 4918, 11.2
   322  	StatusUnprocessableEntityCode                 = "422"
   323  	StatusUnprocessableEntityPhrase               = "Unprocessable Entity"
   324  	StatusLocked                           uint16 = 423 // RFC 4918, 11.3
   325  	StatusLockedCode                              = "423"
   326  	StatusLockedPhrase                            = "Locked"
   327  	StatusFailedDependency                 uint16 = 424 // RFC 4918, 11.4
   328  	StatusFailedDependencyCode                    = "424"
   329  	StatusFailedDependencyPhrase                  = "Failed Dependency"
   330  	StatusUpgradeRequired                  uint16 = 426 // RFC 7231, 6.5.15
   331  	StatusUpgradeRequiredCode                     = "426"
   332  	StatusUpgradeRequiredPhrase                   = "Upgrade Required"
   333  	StatusPreconditionRequired             uint16 = 428 // RFC 6585, 3
   334  	StatusPreconditionRequiredCode                = "428"
   335  	StatusPreconditionRequiredPhrase              = "Precondition Required"
   336  	StatusTooManyRequests                  uint16 = 429 // RFC 6585, 4
   337  	StatusTooManyRequestsCode                     = "429"
   338  	StatusTooManyRequestsPhrase                   = "Too Many Requests"
   339  	StatusHeaderFieldsTooLarge             uint16 = 431 // RFC 6585, 5
   340  	StatusHeaderFieldsTooLargeCode                = "431"
   341  	StatusHeaderFieldsTooLargePhrase              = "Header Fields Too Large"
   342  	StatusUnavailableForLegalReasons       uint16 = 451 // RFC 7725, 3
   343  	StatusUnavailableForLegalReasonsCode          = "451"
   344  	StatusUnavailableForLegalReasonsPhrase        = "Unavailable For Legal Reasons"
   345  
   346  	StatusInternalServerError                 uint16 = 500 // RFC 7231, 6.6.1
   347  	StatusInternalServerErrorCode                    = "500"
   348  	StatusInternalServerErrorPhrase                  = "Internal Server Error"
   349  	StatusNotImplemented                      uint16 = 501 // RFC 7231, 6.6.2
   350  	StatusNotImplementedCode                         = "501"
   351  	StatusNotImplementedPhrase                       = "Not Implemented"
   352  	StatusBadGateway                          uint16 = 502 // RFC 7231, 6.6.3
   353  	StatusBadGatewayCode                             = "502"
   354  	StatusBadGatewayPhrase                           = "Bad Gateway"
   355  	StatusServiceUnavailable                  uint16 = 503 // RFC 7231, 6.6.4
   356  	StatusServiceUnavailableCode                     = "503"
   357  	StatusServiceUnavailablePhrase                   = "Service Unavailable"
   358  	StatusGatewayTimeout                      uint16 = 504 // RFC 7231, 6.6.5
   359  	StatusGatewayTimeoutCode                         = "504"
   360  	StatusGatewayTimeoutPhrase                       = "Gateway Timeout"
   361  	StatusHTTPVersionNotSupported             uint16 = 505 // RFC 7231, 6.6.6
   362  	StatusHTTPVersionNotSupportedCode                = "505"
   363  	StatusHTTPVersionNotSupportedPhrase              = "HTTP Version Not Supported"
   364  	StatusVariantAlsoNegotiates               uint16 = 506 // RFC 2295, 8.1
   365  	StatusVariantAlsoNegotiatesCode                  = "506"
   366  	StatusVariantAlsoNegotiatesPhrase                = "Variant Also Negotiates"
   367  	StatusInsufficientStorage                 uint16 = 507 // RFC 4918, 11.5
   368  	StatusInsufficientStorageCode                    = "507"
   369  	StatusInsufficientStoragePhrase                  = "Insufficient Storage"
   370  	StatusLoopDetected                        uint16 = 508 // RFC 5842, 7.2
   371  	StatusLoopDetectedCode                           = "508"
   372  	StatusLoopDetectedPhrase                         = "Loop Detected"
   373  	StatusNotExtended                         uint16 = 510 // RFC 2774, 7
   374  	StatusNotExtendedCode                            = "510"
   375  	StatusNotExtendedPhrase                          = "Not Extended"
   376  	StatusNetworkAuthenticationRequired       uint16 = 511 // RFC 6585, 6
   377  	StatusNetworkAuthenticationRequiredCode          = "511"
   378  	StatusNetworkAuthenticationRequiredPhrase        = "Network Authentication Required"
   379  )
   380  
   381  var statusText = map[uint16]string{
   382  	StatusContinue:           StatusContinuePhrase,
   383  	StatusSwitchingProtocols: StatusSwitchingProtocolsPhrase,
   384  	StatusProcessing:         StatusProcessingPhrase,
   385  
   386  	StatusOK:                   StatusOKPhrase,
   387  	StatusCreated:              StatusCreatedPhrase,
   388  	StatusAccepted:             StatusAcceptedPhrase,
   389  	StatusNonAuthoritativeInfo: StatusNonAuthoritativeInfoPhrase,
   390  	StatusNoContent:            StatusNoContentPhrase,
   391  	StatusResetContent:         StatusResetContentPhrase,
   392  	StatusPartialContent:       StatusPartialContentPhrase,
   393  	StatusMultiStatus:          StatusMultiStatusPhrase,
   394  	StatusAlreadyReported:      StatusAlreadyReportedPhrase,
   395  	StatusIMUsed:               StatusIMUsedPhrase,
   396  
   397  	StatusMultipleChoices:   StatusMultipleChoicesPhrase,
   398  	StatusMovedPermanently:  StatusMovedPermanentlyPhrase,
   399  	StatusFound:             StatusFoundPhrase,
   400  	StatusSeeOther:          StatusSeeOtherPhrase,
   401  	StatusNotModified:       StatusNotModifiedPhrase,
   402  	StatusUseProxy:          StatusUseProxyPhrase,
   403  	StatusSwitchProxy:       StatusSwitchProxyPhrase,
   404  	StatusTemporaryRedirect: StatusTemporaryRedirectPhrase,
   405  	StatusPermanentRedirect: StatusPermanentRedirectPhrase,
   406  
   407  	StatusBadRequest:                 StatusBadRequestPhrase,
   408  	StatusUnauthorized:               StatusUnauthorizedPhrase,
   409  	StatusPaymentRequired:            StatusPaymentRequiredPhrase,
   410  	StatusForbidden:                  StatusForbiddenPhrase,
   411  	StatusNotFound:                   StatusNotFoundPhrase,
   412  	StatusMethodNotAllowed:           StatusMethodNotAllowedPhrase,
   413  	StatusNotAcceptable:              StatusNotAcceptablePhrase,
   414  	StatusProxyAuthRequired:          StatusProxyAuthRequiredPhrase,
   415  	StatusRequestTimeout:             StatusRequestTimeoutPhrase,
   416  	StatusConflict:                   StatusConflictPhrase,
   417  	StatusGone:                       StatusGonePhrase,
   418  	StatusLengthRequired:             StatusLengthRequiredPhrase,
   419  	StatusPreconditionFailed:         StatusPreconditionFailedPhrase,
   420  	StatusPayloadTooLarge:            StatusPayloadTooLargePhrase,
   421  	StatusURITooLong:                 StatusURITooLongPhrase,
   422  	StatusUnsupportedMediaType:       StatusUnsupportedMediaTypePhrase,
   423  	StatusRangeNotSatisfiable:        StatusRangeNotSatisfiablePhrase,
   424  	StatusExpectationFailed:          StatusExpectationFailedPhrase,
   425  	StatusTeapot:                     StatusTeapotPhrase,
   426  	StatusUnprocessableEntity:        StatusUnprocessableEntityPhrase,
   427  	StatusLocked:                     StatusLockedPhrase,
   428  	StatusFailedDependency:           StatusFailedDependencyPhrase,
   429  	StatusUpgradeRequired:            StatusUpgradeRequiredPhrase,
   430  	StatusPreconditionRequired:       StatusPreconditionRequiredPhrase,
   431  	StatusTooManyRequests:            StatusTooManyRequestsPhrase,
   432  	StatusHeaderFieldsTooLarge:       StatusHeaderFieldsTooLargePhrase,
   433  	StatusUnavailableForLegalReasons: StatusUnavailableForLegalReasonsPhrase,
   434  
   435  	StatusInternalServerError:           StatusInternalServerErrorPhrase,
   436  	StatusNotImplemented:                StatusNotImplementedPhrase,
   437  	StatusBadGateway:                    StatusBadGatewayPhrase,
   438  	StatusServiceUnavailable:            StatusServiceUnavailablePhrase,
   439  	StatusGatewayTimeout:                StatusGatewayTimeoutPhrase,
   440  	StatusHTTPVersionNotSupported:       StatusHTTPVersionNotSupportedPhrase,
   441  	StatusVariantAlsoNegotiates:         StatusVariantAlsoNegotiatesPhrase,
   442  	StatusInsufficientStorage:           StatusInsufficientStoragePhrase,
   443  	StatusLoopDetected:                  StatusLoopDetectedPhrase,
   444  	StatusNotExtended:                   StatusNotExtendedPhrase,
   445  	StatusNetworkAuthenticationRequired: StatusNetworkAuthenticationRequiredPhrase,
   446  }
   447  
   448  // GetStatusText returns a text for the HTTP Status code. It returns the empty
   449  // string if the code is unknown.
   450  func GetStatusText(code uint16) string {
   451  	return statusText[code]
   452  }