github.com/go-board/x-go@v0.1.2-0.20220610024734-db1323f6cb15/xnet/xhttp/const.go (about)

     1  package xhttp
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  type HeaderKey string
     8  
     9  const (
    10  	HeaderAccept                          HeaderKey = "Accept"
    11  	HeaderAcceptCh                                  = "Accept-CH"
    12  	HeaderAcceptChLifetime                          = "Accept-CH-Lifetime"
    13  	HeaderAcceptCharset                             = "Accept-Charset"
    14  	HeaderAcceptEncoding                            = "Accept-Encoding"
    15  	HeaderAcceptLanguage                            = "Accept-Language"
    16  	HeaderAcceptPatch                               = "Accept-Patch"
    17  	HeaderAcceptRange                               = "Accept-Range"
    18  	HeaderAccessControlAllowCredentials             = "Access-Control-Allow-Credentials"
    19  	HeaderAccessControlAllowHeaders                 = "Access-Control-Allow-Headers"
    20  	HeaderAccessControlAllowMethods                 = "Access-Control-Allow-Methods"
    21  	HeaderAccessControlAllowOrigin                  = "Access-Control-Allow-Origin"
    22  	HeaderAccessControlExposeHeaders                = "Access-Control-Expose-Headers"
    23  	HeaderAccessControlMaxAge                       = "Access-Control-Max-Age"
    24  	HeaderAccessControlRequestHeaders               = "Access-Control-Request-Headers"
    25  	HeaderAccessControlRequestMethod                = "Access-Control-Request-Method"
    26  	HeaderAge                                       = "Age"
    27  	HeaderAllow                                     = "Allow"
    28  	HeaderAltSvc                                    = "Alt-Svc"
    29  	HeaderAuthorization                             = "Authorization"
    30  	HeaderCacheControl                              = "Cache-Control"
    31  	HeaderClearSiteData                             = "Clear-Site-Data"
    32  	HeaderConnection                                = "Connection"
    33  	HeaderContentDisposition                        = "Content-Disposition"
    34  	HeaderContentEncoding                           = "Content-Encoding"
    35  	HeaderContentLanguage                           = "Content-Language"
    36  	HeaderContentLength                             = "Content-Length"
    37  	HeaderContentRange                              = "Content-Range"
    38  	HeaderContentSecurityPolicy                     = "Content-Security-Policy"
    39  	HeaderContentSecurityPolicyReportOnly           = "Content-Security-Policy-Report-Only"
    40  	HeaderContentType                               = "Content-Type"
    41  	HeaderCookie                                    = "Cookie"
    42  	HeaderCrossOriginResourcePolicy                 = "Cross-Origin-Resource-Policy"
    43  	HeaderDNT                                       = "DNT"
    44  	HeaderDPR                                       = "DPR"
    45  	HeaderDate                                      = "Date"
    46  	HeaderDeviceMemory                              = "Device-Memory"
    47  	HeaderDigest                                    = "Digest"
    48  	HeaderETag                                      = "ETag"
    49  	HeaderEarlyData                                 = "Early-Data"
    50  	HeaderExpect                                    = "Expect"
    51  	HeaderExpectCT                                  = "Expect-CT"
    52  	HeaderExpires                                   = "Expires"
    53  	HeaderFeaturePolicy                             = "Feature-Policy" // exp
    54  	HeaderForwarded                                 = "Forwarded"
    55  	HeaderFrom                                      = "From"
    56  	HeaderHost                                      = "Host"
    57  	HeaderIfMatch                                   = "If-Match"
    58  	HeaderIfModifiedSince                           = "If-Modified-Since"
    59  	HeaderIfNoneMatch                               = "If-None-Match"
    60  	HeaderIfRange                                   = "If-Range"
    61  	HeaderIfUnmodifiedSince                         = "If-Unmodified-Since"
    62  	HeaderIndex                                     = "Index"
    63  	HeaderKeepAlive                                 = "Keep-Alive"
    64  	HeaderLargeAllocation                           = "Large-Allocation"
    65  	HeaderLastModified                              = "Last-Modified"
    66  	HeaderLink                                      = "Link"
    67  	HeaderLocation                                  = "Location"
    68  	HeaderOrigin                                    = "Origin"
    69  	HeaderPragma                                    = "Pragma"
    70  	HeaderProxyAuthenticate                         = "Proxy-Authenticate"
    71  	HeaderProxyAuthorization                        = "Proxy-Authorization"
    72  	HeaderPublicKeyPins                             = "Public-Key-Pins"
    73  	HeaderPublicKeyPinsReportOnly                   = "Public-Key-Pins-Report-Only"
    74  	HeaderRange                                     = "Range"
    75  	HeaderReferer                                   = "Referer"
    76  	HeaderRefererPolicy                             = "Referer-Policy"
    77  	HeaderRetryAfter                                = "Retry-After"
    78  	HeaderSaveData                                  = "Save-Data"
    79  	HeaderSecFetchDest                              = "Sec-Fetch-Dest"
    80  	HeaderSecFetchMode                              = "Sec-Fetch-Mode"
    81  	HeaderSecFetchSite                              = "Sec-Fetch-Site"
    82  	HeaderSecFetchUser                              = "Sec-Fetch-User"
    83  	HeaderSecWebSocketAccept                        = "Sec-WebSocket-Accept"
    84  	HeaderServer                                    = "Server"
    85  	HeaderServerTiming                              = "Server-Timing"
    86  	HeaderSetCookie                                 = "Set-Cookie"
    87  	HeaderSourceMap                                 = "SourceMap"
    88  	HeaderHTTPStrictTransportSecurity               = "Strict-Transport-Security:"
    89  	HeaderTE                                        = "TE"
    90  	HeaderTimingAllowOrigin                         = "Timing-Allow-Origin"
    91  	HeaderTk                                        = "Tk"
    92  	HeaderTrailer                                   = "Trailer"
    93  	HeaderTransferEncoding                          = "Transfer-Encoding"
    94  	HeaderUpgradeInsecureRequests                   = "Upgrade-Insecure-Requests"
    95  	HeaderUserAgent                                 = "User-Agent"
    96  	HeaderVary                                      = "Vary"
    97  	HeaderVia                                       = "Via"
    98  	HeaderWWWAuthenticate                           = "WWW-Authenticate"
    99  	HeaderWantDigest                                = "Want-Digest"
   100  	HeaderWarning                                   = "Warning"
   101  	HeaderXContentTypeOptions                       = "X-Content-Type-Options"
   102  	HeaderXDNSPrefetchControl                       = "X-DNS-Prefetch-Control"
   103  	HeaderXForwardedFor                             = "X-Forwarded-For"
   104  	HeaderXForwardedHost                            = "X-Forwarded-Host"
   105  	HeaderXForwardedProto                           = "X-Forwarded-Proto"
   106  	HeaderXFrameOptions                             = "X-Frame-Options"
   107  	HeaderXXSSProtection                            = "X-XSS-Protection"
   108  
   109  	HeaderXRequestID     = "X-Request-ID"
   110  	HeaderXRequestDevice = "X-Request-Device"
   111  	HeaderXRequestUser   = "X-Request-User"
   112  )
   113  
   114  func LowerHeader(h string) string {
   115  	return strings.Map(func(r rune) rune {
   116  		if r >= 'A' && r <= 'Z' {
   117  			return r - 26
   118  		}
   119  		return r
   120  	}, h)
   121  }
   122  
   123  type Mime string
   124  
   125  const (
   126  	charsetUTF8 = "charset=UTF-8"
   127  
   128  	MIMEApplicationJSON                  = "application/json"
   129  	MIMEApplicationJSONCharsetUTF8       = MIMEApplicationJSON + "; " + charsetUTF8
   130  	MIMEApplicationJavaScript            = "application/javascript"
   131  	MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8
   132  	MIMEApplicationXML                   = "application/xml"
   133  	MIMEApplicationXMLCharsetUTF8        = MIMEApplicationXML + "; " + charsetUTF8
   134  	MIMETextXML                          = "text/xml"
   135  	MIMETextXMLCharsetUTF8               = MIMETextXML + "; " + charsetUTF8
   136  	MIMEApplicationForm                  = "application/x-www-form-urlencoded"
   137  	MIMEApplicationProtobuf              = "application/protobuf"
   138  	MIMEApplicationMsgpack               = "application/msgpack"
   139  	MIMETextHTML                         = "text/html"
   140  	MIMETextHTMLCharsetUTF8              = MIMETextHTML + "; " + charsetUTF8
   141  	MIMETextPlain                        = "text/plain"
   142  	MIMETextPlainCharsetUTF8             = MIMETextPlain + "; " + charsetUTF8
   143  	MIMEMultipartForm                    = "multipart/form-data"
   144  	MIMEOctetStream                      = "application/octet-stream"
   145  )