Last active
August 25, 2022 02:24
-
-
Save nehemiahj/077e26face9a3d4ef7566e5bc6414bb5 to your computer and use it in GitHub Desktop.
Read custom header to generate webp format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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