Skip to content

Instantly share code, notes, and snippets.

@nehemiahj
Last active August 25, 2022 02:24
Show Gist options
  • Save nehemiahj/077e26face9a3d4ef7566e5bc6414bb5 to your computer and use it in GitHub Desktop.
Save nehemiahj/077e26face9a3d4ef7566e5bc6414bb5 to your computer and use it in GitHub Desktop.
Read custom header to generate webp format
public virtual string GetSupportedFormats(HttpContextBase context)
{
var acceptTypes = context?.Request?.AcceptTypes ?? new string[] { };
if (acceptTypes.Any())
{
return PipelineHelpers.RunDianogaGetSupportedFormatsPipeline(acceptTypes);
}
var customAccept = context?.Request?.Headers?["customAccept"];
if (!string.IsNullOrEmpty(customAccept))
return PipelineHelpers.RunDianogaGetSupportedFormatsPipeline(new string[] { customAccept });
return string.Empty;
}
public virtual bool CheckSupportedFormat(HttpContextBase context, string extension)
{
var acceptTypes = context?.Request?.AcceptTypes ?? new string[] { };
if (acceptTypes.Any())
return CheckSupportedFormat(string.Join(",", acceptTypes), extension);
var customAccept = context?.Request?.Headers?["customAccept"];
if (!string.IsNullOrEmpty(customAccept))
return CheckSupportedFormat(customAccept, extension);
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment