public override bool CanExecute(AceeptHeaderEnricherContext context) { if (string.IsNullOrEmpty(context.FormatFromQuery)) { return(false); } return(true); }
public override bool CanExecute(AceeptHeaderEnricherContext context) { if (context.Accept == null || context.Accept.Any(a => string.IsNullOrEmpty(a.Charset) == false) == false) { return(false); } if (context.AcceptCharset != null && context.AcceptCharset.Any()) { return(false); } return(true); }
public override bool CanExecute(AceeptHeaderEnricherContext context) { if (context.Accept == null || context.Accept.Any() == false) { return(false); } //Если есть формат с Url то Accept устанавливать не нужно if (string.IsNullOrEmpty(context.FormatFromQuery) == false) { return(false); } return(true); }
public async Task Invoke(HttpContext context) { var aceeptHeaderEnricherContext = new AceeptHeaderEnricherContext(context, _options); foreach (var aceeptHeaderEnricher in _aceeptHeaderEnrichers.Where(a => a.CanExecute(aceeptHeaderEnricherContext))) { aceeptHeaderEnricher.Execute(aceeptHeaderEnricherContext); } var acceptHeaders = new List <MediaTypeSegmentWithQuality>(); AcceptHeaderParser.ParseAcceptHeader(context.Request.Headers[HeaderNames.Accept], acceptHeaders); context.Features.Set <IOutputFormatter>(OutputFormatterSelector.SelectFormatter(_options.Value.OutputFormatters.OfType <TextOutputFormatter>(), acceptHeaders)); await _next(context); }
public override bool CanExecute(AceeptHeaderEnricherContext context) { if (string.IsNullOrEmpty(context.ContentType?.Charset)) { return(false); } if (context.Accept != null && context.Accept.Any(a => string.IsNullOrEmpty(a.Charset) == false)) { return(false); } //Если установлен AcceptCharset из ContentType устанавливать не нужно if (context.AcceptCharset != null && context.AcceptCharset.Any()) { return(false); } return(true); }
public override void Execute(AceeptHeaderEnricherContext context) { context.Context.Request.Headers.Remove(HeaderNames.Accept); context.Context.Request.Headers.Append(HeaderNames.Accept, context.FormatFromQuery); }
public override void Execute(AceeptHeaderEnricherContext context) { context.Context.Request.Headers.Append(HeaderNames.AcceptCharset, string.Join(",", context.Accept.Select(a => $"{a.Charset}{BuildQualityString(a)}"))); }
public override void Execute(AceeptHeaderEnricherContext context) { context.Context.Request.Headers.Append(HeaderNames.AcceptCharset, $"{context.ContentType.Charset}{BuildQualityString(context.ContentType)}"); }
public abstract void Execute(AceeptHeaderEnricherContext context);
public abstract bool CanExecute(AceeptHeaderEnricherContext context);