Skip to content

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

@JamoCA

Description

@JamoCA

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions