// AcceptType returns the most preferred content type from the HTTP Accept header.
// If nothing accepted, then empty string is returned.
177079
func (ctx *Context) AcceptType(preferred ...string) string {
	return negotiator.New(ctx.Req.Header).Type(preferred...)
}
1127439
func isContentType(h http.Header, contentType string) bool {
	ct := h.Get("Content-Type")
	if i := strings.IndexRune(ct, ';'); i != -1 {
		ct = ct[0:i]
	}
	return ct == contentType
}
976151
func (s *acceptFirst) Accept(from interface{}) bool {
	if _, ok := s.handled[from]; ok {
		return false
	}
	s.handled[from] = struct{}{}
	return true
}
551631
func (r *SearchRequest) SearchType(searchType string) *SearchRequest {
	r.searchType = searchType
	return r
}
339022
func WithContentType(handler http.Handler, contentType string) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", contentType)
		w.Header().Set("X-Content-Type-Options", "nosniff")
		handler.ServeHTTP(w, r)
	})
}
891076
func ContentType(ctypes ...string) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		if contentMethod(r.Method) && !checkCT(r.Header.Get("Content-Type"), ctypes...) {
			w.WriteHeader(http.StatusUnsupportedMediaType)
		}
	}
}
146391
func ContentType(typ string) {
	if mt, ok := mediaTypeDefinition(); ok {
		mt.ContentType = typ
	}
}
347332
func (h AcceptHeader) Quality(contentType string, params map[string][]string) float64 {
	results := make(mediaRangeMatches, 0, len(h))
	for i := range h {
		mr := &h[i]
		if m := mr.match(contentType, params); m.Valid {
			results = append(results, m)
		}
	}
	if len(results) == 0 {
		return 0.0
	}

	// find most specific
	i := 0
	for j := 1; j < results.Len(); j++ {
		if results.Less(j, i) {
			i = j
		}
	}
	return results[i].MediaRange.Quality
}
173789
func (s *ValidateService) Type(typ ...string) *ValidateService {
	s.typ = append(s.typ, typ...)
	return s
}
107059
func (listener *httpListener) Accept() (conn net.Conn, err error) {
	result, ok := <-listener.acceptCh
	if ok {
		return result.conn, result.err
	}

	return nil, syscall.EINVAL
}
917018
func (r *Request) Type(name string) *Request {
	r.Use(bodytype.Set(name))
	return r
}
436758
func Type(opts ...*TypeOpts) fibre.MiddlewareFunc {
	return func(h fibre.HandlerFunc) fibre.HandlerFunc {
		return func(c *fibre.Context) error {

			var config *TypeOpts

			switch len(opts) {
			case 0:
				return h(c)
			default:
				config = opts[0]
			}

			// This is a socket
			if c.IsSocket() {
				return h(c)
			}

			// No config has been set
			if len(config.AllowedContent) == 0 {
				return h(c)
			}

			// Content type is within allowed types
			if _, ok := config.AllowedContent[c.Type()]; ok {
				return h(c)
			}

			return fibre.NewHTTPError(415)

		}
	}
}
432218
func (t *precompilationTypeChecker) AcceptVariable(v tree.Variable) {
	t.result = fmt.Errorf("no variables allowed - this is probably a programmer error: %s", v.Name)
}
850136
func (res *Response) ContentType() string {
	return mime.FormatMediaType(res.MediaType, map[string]string{"charset": res.Charset})
}
309178
func (s *UpdateByQueryService) SearchType(searchType string) *UpdateByQueryService {
	s.searchType = searchType
	return s
}
111266
func (s *SearchService) SearchType(searchType string) *SearchService {
	s.searchType = searchType
	return s
}
1184968
func (t *precompilationTypeChecker) AcceptNegation(v tree.Negation) {
	if res := checkPrecompilationRules(v.Operand); res != nil {
		t.result = res
	}
}