Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultMime not working with Chrome, Microsoft Edge or Firefox address bar requests #441

Open
JamoCA opened this issue Apr 18, 2024 · 0 comments

Comments

@JamoCA
Copy link
Contributor

JamoCA commented Apr 18, 2024

I configured the application's defaultMime to be json. The customSerializer.cfc is configured with getAsJson as default, but it doesn't seem to be working

Chromium appears to be using the following as the request Accept header rather than something generic like "/". (I'm testing using Microsoft EdgeDev with a work profile.)

text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7

Firefox 125.0.1 uses the following Accept header:

text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8

I've updated core.buildRequestArguments() to check for overloading of the Accept header to return defaultMime when both text/html and image/ are used so that the configured default mime works.

<cfelseif structKeyExists(arguments.headers, "Accept") && findnocase("text/html", arguments.headers.accept) && findnocase("image/", arguments.headers.accept)>
	<cfset local.returnData["_taffy_mime"] = application._taffy.settings.defaultMime>
<cfelseif structKeyExists(arguments.headers, "Accept")>...

Is this a good approach? I don't believe that explicit API requests for XML will use an Accept header that includes both text/html and image/, but I could be wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant