// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
// 🤖 Github Repository: https://github.com/gofiber/fiber
// 📌 API Documentation: https://docs.gofiber.io

package fiber

import (
	
	
	
	
	
	
	
	
	
	
	
	

	
	

	
	
)

// acceptType is a struct that holds the parsed value of an Accept header
// along with quality, specificity, and order.
// used for sorting accept headers.
type acceptedType struct {
	spec        string
	quality     float64
	specificity int
	order       int
}

// getTLSConfig returns a net listener's tls config
func getTLSConfig( net.Listener) *tls.Config {
	// Get listener type
	 := reflect.ValueOf()

	// Is it a tls.listener?
	if .String() == "<*tls.listener Value>" {
		// Copy value from pointer
		if  := reflect.Indirect(); .Type() != nil {
			// Get private field from value
			if  := .FieldByName("config"); .Type() != nil {
				// Copy value from pointer field (unsafe)
				 := reflect.NewAt(.Type(), unsafe.Pointer(.UnsafeAddr())) //nolint:gosec // Probably the only way to extract the *tls.Config from a net.Listener. TODO: Verify there really is no easier way without using unsafe.
				if .Type() != nil {
					// Get element from pointer
					if  := .Elem(); .Type() != nil {
						// Cast value to *tls.Config
						,  := .Interface().(*tls.Config)
						if ! {
							panic(fmt.Errorf("failed to type-assert to *tls.Config"))
						}
						return 
					}
				}
			}
		}
	}

	return nil
}

// readContent opens a named file and read content from it
func readContent( io.ReaderFrom,  string) (int64, error) {
	// Read file
	,  := os.Open(filepath.Clean())
	if  != nil {
		return 0, fmt.Errorf("failed to open: %w", )
	}
	defer func() {
		if  = .Close();  != nil {
			log.Errorf("Error closing file: %s", )
		}
	}()
	if ,  := .ReadFrom();  != nil {
		return , fmt.Errorf("failed to read: %w", )
	}
	return 0, nil
}

// quoteString escape special characters in a given string
func ( *App) ( string) string {
	 := bytebufferpool.Get()
	// quoted := string(fasthttp.AppendQuotedArg(bb.B, getBytes(raw)))
	 := .getString(fasthttp.AppendQuotedArg(.B, .getBytes()))
	bytebufferpool.Put()
	return 
}

// Scan stack if other methods match the request
func ( *App) ( *Ctx) bool {
	var  bool
	 := .config.RequestMethods
	for  := 0;  < len(); ++ {
		// Skip original method
		if .methodINT ==  {
			continue
		}
		// Reset stack index
		 := -1
		,  := .app.treeStack[][.treePath]
		if ! {
			 = .app.treeStack[][""]
		}
		// Get stack length
		 := len() - 1
		// Loop over the route stack starting from previous index
		for  <  {
			// Increment route index
			++
			// Get *Route
			 := []
			// Skip use routes
			if .use {
				continue
			}
			// Check if it matches the request path
			 := .match(.detectionPath, .path, &.values)
			// No match, next route
			if  {
				// We matched
				 = true
				// Add method to Allow header
				.Append(HeaderAllow, [])
				// Break stack loop
				break
			}
		}
	}
	return 
}

// uniqueRouteStack drop all not unique routes from the slice
func uniqueRouteStack( []*Route) []*Route {
	var  []*Route
	 := make(map[*Route]int)
	for ,  := range  {
		if ,  := []; ! {
			// Unique key found. Record position and collect
			// in result.
			[] = len()
			 = append(, )
		}
	}

	return 
}

// defaultString returns the value or a default value if it is set
func defaultString( string,  []string) string {
	if len() == 0 && len() > 0 {
		return [0]
	}
	return 
}

const normalizedHeaderETag = "Etag"

// Generate and set ETag header to response
func setETag( *Ctx,  bool) { //nolint: revive // Accepting a bool param is fine here
	// Don't generate ETags for invalid responses
	if .fasthttp.Response.StatusCode() != StatusOK {
		return
	}
	 := .fasthttp.Response.Body()
	// Skips ETag if no response body is present
	if len() == 0 {
		return
	}
	// Get ETag header from request
	 := .Get(HeaderIfNoneMatch)

	// Generate ETag for response
	const  = 0xD5828281
	 := crc32.MakeTable()
	 := fmt.Sprintf("\"%d-%v\"", len(), crc32.Checksum(, ))

	// Enable weak tag
	if  {
		 = "W/" + 
	}

	// Check if client's ETag is weak
	if strings.HasPrefix(, "W/") {
		// Check if server's ETag is weak
		if [2:] ==  || [2:] == [2:] {
			// W/1 == 1 || W/1 == W/1
			if  := .SendStatus(StatusNotModified);  != nil {
				log.Errorf("setETag: failed to SendStatus: %v", )
			}
			.fasthttp.ResetBody()
			return
		}
		// W/1 != W/2 || W/1 != 2
		.setCanonical(normalizedHeaderETag, )
		return
	}
	if strings.Contains(, ) {
		// 1 == 1
		if  := .SendStatus(StatusNotModified);  != nil {
			log.Errorf("setETag: failed to SendStatus: %v", )
		}
		.fasthttp.ResetBody()
		return
	}
	// 1 != 2
	.setCanonical(normalizedHeaderETag, )
}

func getGroupPath(,  string) string {
	if len() == 0 {
		return 
	}

	if [0] != '/' {
		 = "/" + 
	}

	return utils.TrimRight(, '/') + 
}

// acceptsOffer This function determines if an offer matches a given specification.
// It checks if the specification ends with a '*' or if the offer has the prefix of the specification.
// Returns true if the offer matches the specification, false otherwise.
func acceptsOffer(,  string) bool {
	if len() >= 1 && [len()-1] == '*' {
		return true
	} else if strings.HasPrefix(, ) {
		return true
	}
	return false
}

// acceptsOfferType This function determines if an offer type matches a given specification.
// It checks if the specification is equal to */* (i.e., all types are accepted).
// It gets the MIME type of the offer (either from the offer itself or by its file extension).
// It checks if the offer MIME type matches the specification MIME type or if the specification is of the form <MIME_type>/* and the offer MIME type has the same MIME type.
// Returns true if the offer type matches the specification, false otherwise.
func acceptsOfferType(,  string) bool {
	// Accept: */*
	if  == "*/*" {
		return true
	}

	var  string
	if strings.IndexByte(, '/') != -1 {
		 =  // MIME type
	} else {
		 = utils.GetMIME() // extension
	}

	if  ==  {
		// Accept: <MIME_type>/<MIME_subtype>
		return true
	}

	 := strings.IndexByte(, '/')
	// Accept: <MIME_type>/*
	if strings.HasPrefix(, [:]) && ([:] == "/*" || [:] == "/*") {
		return true
	}

	return false
}

// getSplicedStrList function takes a string and a string slice as an argument, divides the string into different
// elements divided by ',' and stores these elements in the string slice.
// It returns the populated string slice as an output.
//
// If the given slice hasn't enough space, it will allocate more and return.
func getSplicedStrList( string,  []string) []string {
	if  == "" {
		return nil
	}

	var (
		             int
		         rune
		 uint8
		       int
	)
	for ,  = range  + "$" {
		if  == ',' ||  == len() {
			if  >= len() {
				 := 
				 = make([]string, len()+(len()>>1)+2)
				copy(, )
			}
			[] = utils.TrimLeft([:], ' ')
			 = uint8( + 1)
			++
		}
	}

	if len() >  {
		 = [:]
	}
	return 
}

// getOffer return valid offer for header negotiation
func getOffer( string,  func(,  string) bool,  ...string) string {
	if len() == 0 {
		return ""
	}
	if  == "" {
		return [0]
	}

	// Parse header and get accepted types with their quality and specificity
	// See: https://www.rfc-editor.org/rfc/rfc9110#name-content-negotiation-fields
	, ,  := "", 0, 0
	 := make([]acceptedType, 0, 20)
	for len() > 0 {
		++

		// Skip spaces
		 = utils.TrimLeft(, ' ')

		// Get spec
		 = strings.IndexByte(, ',')
		if  != -1 {
			 = utils.Trim([:], ' ')
		} else {
			 = utils.TrimLeft(, ' ')
		}

		// Get quality
		 := 1.0
		if  := strings.IndexByte(, ';');  != -1 {
			 := utils.Trim([+1:], ' ')
			if strings.HasPrefix(, "q=") {
				if ,  := fasthttp.ParseUfloat(utils.UnsafeBytes([2:]));  == nil {
					 = 
				}
			}
			 = [:]
		}

		// Skip if quality is 0.0
		// See: https://www.rfc-editor.org/rfc/rfc9110#quality.values
		if  == 0.0 {
			if  != -1 {
				 = [+1:]
			} else {
				break
			}
			continue
		}

		// Get specificity
		 := 0
		// check for wildcard this could be a mime */* or a wildcard character *
		if  == "*/*" ||  == "*" {
			 = 1
		} else if strings.HasSuffix(, "/*") {
			 = 2
		} else if strings.IndexByte(, '/') != -1 {
			 = 3
		} else {
			 = 4
		}

		// Add to accepted types
		 = append(, acceptedType{, , , })

		// Next
		if  != -1 {
			 = [+1:]
		} else {
			break
		}
	}

	if len() > 1 {
		// Sort accepted types by quality and specificity, preserving order of equal elements
		sortAcceptedTypes(&)
	}

	// Find the first offer that matches the accepted types
	for ,  := range  {
		for ,  := range  {
			if len() == 0 {
				continue
			}
			if (.spec, ) {
				return 
			}
		}
	}

	return ""
}

// sortAcceptedTypes sorts accepted types by quality and specificity, preserving order of equal elements
//
// Parameters are not supported, they are ignored when sorting by specificity.
//
// See: https://www.rfc-editor.org/rfc/rfc9110#name-content-negotiation-fields
func sortAcceptedTypes( *[]acceptedType) {
	if  == nil || len(*) < 2 {
		return
	}
	 := *

	for  := 1;  < len(); ++ {
		,  := 0, -1
		for  <=  {
			 := ( + ) / 2
			if [].quality < [].quality ||
				([].quality == [].quality && [].specificity < [].specificity) ||
				([].quality == [].quality && [].specificity == [].specificity && [].order > [].order) {
				 =  + 1
			} else {
				 =  - 1
			}
		}
		for  := ;  > ; -- {
			[-1], [] = [], [-1]
		}
	}
}

func matchEtag(,  string) bool {
	if  ==  ||  == "W/"+ || "W/"+ ==  {
		return true
	}

	return false
}

func ( *App) ( string,  []byte) bool {
	var ,  int

	// Adapted from:
	// https://github.com/jshttp/fresh/blob/10e0471669dbbfbfd8de65bc6efac2ddd0bfa057/index.js#L110
	for  := range  {
		switch [] {
		case 0x20:
			if  ==  {
				 =  + 1
				 =  + 1
			}
		case 0x2c:
			if matchEtag(.getString([:]), ) {
				return false
			}
			 =  + 1
			 =  + 1
		default:
			 =  + 1
		}
	}

	return !matchEtag(.getString([:]), )
}

func parseAddr( string) (string, string) { //nolint:revive // Returns (host, port)
	if  := strings.LastIndex(, ":");  != -1 {
		return [:], [+1:]
	}
	return , ""
}

const noCacheValue = "no-cache"

// isNoCache checks if the cacheControl header value is a `no-cache`.
func isNoCache( string) bool {
	 := strings.Index(, noCacheValue)
	if  == -1 {
		return false
	}

	// Xno-cache
	if  > 0 && !([-1] == ' ' || [-1] == ',') {
		return false
	}

	// bla bla, no-cache
	if +len(noCacheValue) == len() {
		return true
	}

	// bla bla, no-cacheX
	if [+len(noCacheValue)] != ',' {
		return false
	}

	// OK
	return true
}

type testConn struct {
	r bytes.Buffer
	w bytes.Buffer
}

func ( *testConn) ( []byte) (int, error)  { return .r.Read() }  //nolint:wrapcheck // This must not be wrapped
func ( *testConn) ( []byte) (int, error) { return .w.Write() } //nolint:wrapcheck // This must not be wrapped
func (*testConn) () error                  { return nil }

func (*testConn) () net.Addr                { return &net.TCPAddr{Port: 0, Zone: "", IP: net.IPv4zero} }
func (*testConn) () net.Addr               { return &net.TCPAddr{Port: 0, Zone: "", IP: net.IPv4zero} }
func (*testConn) ( time.Time) error      { return nil }
func (*testConn) ( time.Time) error  { return nil }
func (*testConn) ( time.Time) error { return nil }

func getStringImmutable( []byte) string {
	return string()
}

func getBytesImmutable( string) []byte {
	return []byte()
}

// HTTP methods and their unique INTs
func ( *App) ( string) int {
	// For better performance
	if len(.configured.RequestMethods) == 0 {
		// TODO: Use iota instead
		switch  {
		case MethodGet:
			return 0
		case MethodHead:
			return 1
		case MethodPost:
			return 2
		case MethodPut:
			return 3
		case MethodDelete:
			return 4
		case MethodConnect:
			return 5
		case MethodOptions:
			return 6
		case MethodTrace:
			return 7
		case MethodPatch:
			return 8
		default:
			return -1
		}
	}

	// For method customization
	for ,  := range .config.RequestMethods {
		if  ==  {
			return 
		}
	}

	return -1
}

// IsMethodSafe reports whether the HTTP method is considered safe.
// See https://datatracker.ietf.org/doc/html/rfc9110#section-9.2.1
func ( string) bool {
	switch  {
	case MethodGet,
		MethodHead,
		MethodOptions,
		MethodTrace:
		return true
	default:
		return false
	}
}

// IsMethodIdempotent reports whether the HTTP method is considered idempotent.
// See https://datatracker.ietf.org/doc/html/rfc9110#section-9.2.2
func ( string) bool {
	if IsMethodSafe() {
		return true
	}

	switch  {
	case MethodPut, MethodDelete:
		return true
	default:
		return false
	}
}

// HTTP methods were copied from net/http.
const (
	MethodGet     = "GET"     // RFC 7231, 4.3.1
	MethodHead    = "HEAD"    // RFC 7231, 4.3.2
	MethodPost    = "POST"    // RFC 7231, 4.3.3
	MethodPut     = "PUT"     // RFC 7231, 4.3.4
	MethodPatch   = "PATCH"   // RFC 5789
	MethodDelete  = "DELETE"  // RFC 7231, 4.3.5
	MethodConnect = "CONNECT" // RFC 7231, 4.3.6
	MethodOptions = "OPTIONS" // RFC 7231, 4.3.7
	MethodTrace   = "TRACE"   // RFC 7231, 4.3.8
	methodUse     = "USE"
)

// MIME types that are commonly used
const (
	MIMETextXML         = "text/xml"
	MIMETextHTML        = "text/html"
	MIMETextPlain       = "text/plain"
	MIMETextJavaScript  = "text/javascript"
	MIMEApplicationXML  = "application/xml"
	MIMEApplicationJSON = "application/json"
	// Deprecated: use MIMETextJavaScript instead
	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"
	MIMETextJavaScriptCharsetUTF8  = "text/javascript; charset=utf-8"
	MIMEApplicationXMLCharsetUTF8  = "application/xml; charset=utf-8"
	MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8"
	// Deprecated: use MIMETextJavaScriptCharsetUTF8 instead
	MIMEApplicationJavaScriptCharsetUTF8 = "application/javascript; charset=utf-8"
)

// HTTP status codes were copied from net/http with the following updates:
// - Rename StatusNonAuthoritativeInfo to StatusNonAuthoritativeInformation
// - Add StatusSwitchProxy (306)
// NOTE: Keep this list in sync with statusMessage
const (
	StatusContinue           = 100 // RFC 9110, 15.2.1
	StatusSwitchingProtocols = 101 // RFC 9110, 15.2.2
	StatusProcessing         = 102 // RFC 2518, 10.1
	StatusEarlyHints         = 103 // RFC 8297

	StatusOK                          = 200 // RFC 9110, 15.3.1
	StatusCreated                     = 201 // RFC 9110, 15.3.2
	StatusAccepted                    = 202 // RFC 9110, 15.3.3
	StatusNonAuthoritativeInformation = 203 // RFC 9110, 15.3.4
	StatusNoContent                   = 204 // RFC 9110, 15.3.5
	StatusResetContent                = 205 // RFC 9110, 15.3.6
	StatusPartialContent              = 206 // RFC 9110, 15.3.7
	StatusMultiStatus                 = 207 // RFC 4918, 11.1
	StatusAlreadyReported             = 208 // RFC 5842, 7.1
	StatusIMUsed                      = 226 // RFC 3229, 10.4.1

	StatusMultipleChoices   = 300 // RFC 9110, 15.4.1
	StatusMovedPermanently  = 301 // RFC 9110, 15.4.2
	StatusFound             = 302 // RFC 9110, 15.4.3
	StatusSeeOther          = 303 // RFC 9110, 15.4.4
	StatusNotModified       = 304 // RFC 9110, 15.4.5
	StatusUseProxy          = 305 // RFC 9110, 15.4.6
	StatusSwitchProxy       = 306 // RFC 9110, 15.4.7 (Unused)
	StatusTemporaryRedirect = 307 // RFC 9110, 15.4.8
	StatusPermanentRedirect = 308 // RFC 9110, 15.4.9

	StatusBadRequest                   = 400 // RFC 9110, 15.5.1
	StatusUnauthorized                 = 401 // RFC 9110, 15.5.2
	StatusPaymentRequired              = 402 // RFC 9110, 15.5.3
	StatusForbidden                    = 403 // RFC 9110, 15.5.4
	StatusNotFound                     = 404 // RFC 9110, 15.5.5
	StatusMethodNotAllowed             = 405 // RFC 9110, 15.5.6
	StatusNotAcceptable                = 406 // RFC 9110, 15.5.7
	StatusProxyAuthRequired            = 407 // RFC 9110, 15.5.8
	StatusRequestTimeout               = 408 // RFC 9110, 15.5.9
	StatusConflict                     = 409 // RFC 9110, 15.5.10
	StatusGone                         = 410 // RFC 9110, 15.5.11
	StatusLengthRequired               = 411 // RFC 9110, 15.5.12
	StatusPreconditionFailed           = 412 // RFC 9110, 15.5.13
	StatusRequestEntityTooLarge        = 413 // RFC 9110, 15.5.14
	StatusRequestURITooLong            = 414 // RFC 9110, 15.5.15
	StatusUnsupportedMediaType         = 415 // RFC 9110, 15.5.16
	StatusRequestedRangeNotSatisfiable = 416 // RFC 9110, 15.5.17
	StatusExpectationFailed            = 417 // RFC 9110, 15.5.18
	StatusTeapot                       = 418 // RFC 9110, 15.5.19 (Unused)
	StatusMisdirectedRequest           = 421 // RFC 9110, 15.5.20
	StatusUnprocessableEntity          = 422 // RFC 9110, 15.5.21
	StatusLocked                       = 423 // RFC 4918, 11.3
	StatusFailedDependency             = 424 // RFC 4918, 11.4
	StatusTooEarly                     = 425 // RFC 8470, 5.2.
	StatusUpgradeRequired              = 426 // RFC 9110, 15.5.22
	StatusPreconditionRequired         = 428 // RFC 6585, 3
	StatusTooManyRequests              = 429 // RFC 6585, 4
	StatusRequestHeaderFieldsTooLarge  = 431 // RFC 6585, 5
	StatusUnavailableForLegalReasons   = 451 // RFC 7725, 3

	StatusInternalServerError           = 500 // RFC 9110, 15.6.1
	StatusNotImplemented                = 501 // RFC 9110, 15.6.2
	StatusBadGateway                    = 502 // RFC 9110, 15.6.3
	StatusServiceUnavailable            = 503 // RFC 9110, 15.6.4
	StatusGatewayTimeout                = 504 // RFC 9110, 15.6.5
	StatusHTTPVersionNotSupported       = 505 // RFC 9110, 15.6.6
	StatusVariantAlsoNegotiates         = 506 // RFC 2295, 8.1
	StatusInsufficientStorage           = 507 // RFC 4918, 11.5
	StatusLoopDetected                  = 508 // RFC 5842, 7.2
	StatusNotExtended                   = 510 // RFC 2774, 7
	StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6
)

// Errors
var (
	ErrBadRequest                   = NewError(StatusBadRequest)                   // 400
	ErrUnauthorized                 = NewError(StatusUnauthorized)                 // 401
	ErrPaymentRequired              = NewError(StatusPaymentRequired)              // 402
	ErrForbidden                    = NewError(StatusForbidden)                    // 403
	ErrNotFound                     = NewError(StatusNotFound)                     // 404
	ErrMethodNotAllowed             = NewError(StatusMethodNotAllowed)             // 405
	ErrNotAcceptable                = NewError(StatusNotAcceptable)                // 406
	ErrProxyAuthRequired            = NewError(StatusProxyAuthRequired)            // 407
	ErrRequestTimeout               = NewError(StatusRequestTimeout)               // 408
	ErrConflict                     = NewError(StatusConflict)                     // 409
	ErrGone                         = NewError(StatusGone)                         // 410
	ErrLengthRequired               = NewError(StatusLengthRequired)               // 411
	ErrPreconditionFailed           = NewError(StatusPreconditionFailed)           // 412
	ErrRequestEntityTooLarge        = NewError(StatusRequestEntityTooLarge)        // 413
	ErrRequestURITooLong            = NewError(StatusRequestURITooLong)            // 414
	ErrUnsupportedMediaType         = NewError(StatusUnsupportedMediaType)         // 415
	ErrRequestedRangeNotSatisfiable = NewError(StatusRequestedRangeNotSatisfiable) // 416
	ErrExpectationFailed            = NewError(StatusExpectationFailed)            // 417
	ErrTeapot                       = NewError(StatusTeapot)                       // 418
	ErrMisdirectedRequest           = NewError(StatusMisdirectedRequest)           // 421
	ErrUnprocessableEntity          = NewError(StatusUnprocessableEntity)          // 422
	ErrLocked                       = NewError(StatusLocked)                       // 423
	ErrFailedDependency             = NewError(StatusFailedDependency)             // 424
	ErrTooEarly                     = NewError(StatusTooEarly)                     // 425
	ErrUpgradeRequired              = NewError(StatusUpgradeRequired)              // 426
	ErrPreconditionRequired         = NewError(StatusPreconditionRequired)         // 428
	ErrTooManyRequests              = NewError(StatusTooManyRequests)              // 429
	ErrRequestHeaderFieldsTooLarge  = NewError(StatusRequestHeaderFieldsTooLarge)  // 431
	ErrUnavailableForLegalReasons   = NewError(StatusUnavailableForLegalReasons)   // 451

	ErrInternalServerError           = NewError(StatusInternalServerError)           // 500
	ErrNotImplemented                = NewError(StatusNotImplemented)                // 501
	ErrBadGateway                    = NewError(StatusBadGateway)                    // 502
	ErrServiceUnavailable            = NewError(StatusServiceUnavailable)            // 503
	ErrGatewayTimeout                = NewError(StatusGatewayTimeout)                // 504
	ErrHTTPVersionNotSupported       = NewError(StatusHTTPVersionNotSupported)       // 505
	ErrVariantAlsoNegotiates         = NewError(StatusVariantAlsoNegotiates)         // 506
	ErrInsufficientStorage           = NewError(StatusInsufficientStorage)           // 507
	ErrLoopDetected                  = NewError(StatusLoopDetected)                  // 508
	ErrNotExtended                   = NewError(StatusNotExtended)                   // 510
	ErrNetworkAuthenticationRequired = NewError(StatusNetworkAuthenticationRequired) // 511
)

// HTTP Headers were copied from 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"
	// Deprecated: use HeaderPermissionsPolicy instead
	HeaderFeaturePolicy           = "Feature-Policy"
	HeaderPermissionsPolicy       = "Permissions-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"
)

// Network types that are commonly used
const (
	NetworkTCP  = "tcp"
	NetworkTCP4 = "tcp4"
	NetworkTCP6 = "tcp6"
)

// Compression types
const (
	StrGzip    = "gzip"
	StrBr      = "br"
	StrDeflate = "deflate"
	StrBrotli  = "brotli"
)

// Cookie SameSite
// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
const (
	CookieSameSiteDisabled   = "disabled" // not in RFC, just control "SameSite" attribute will not be set.
	CookieSameSiteLaxMode    = "lax"
	CookieSameSiteStrictMode = "strict"
	CookieSameSiteNoneMode   = "none"
)

// Route Constraints
const (
	ConstraintInt             = "int"
	ConstraintBool            = "bool"
	ConstraintFloat           = "float"
	ConstraintAlpha           = "alpha"
	ConstraintGuid            = "guid" //nolint:revive,stylecheck // TODO: Rename to "ConstraintGUID" in v3
	ConstraintMinLen          = "minLen"
	ConstraintMaxLen          = "maxLen"
	ConstraintLen             = "len"
	ConstraintBetweenLen      = "betweenLen"
	ConstraintMinLenLower     = "minlen"
	ConstraintMaxLenLower     = "maxlen"
	ConstraintBetweenLenLower = "betweenlen"
	ConstraintMin             = "min"
	ConstraintMax             = "max"
	ConstraintRange           = "range"
	ConstraintDatetime        = "datetime"
	ConstraintRegex           = "regex"
)

func ( string,  int32) bool {
	for ,  := range  {
		if  ==  {
			return true
		}
	}
	return false
}