openculinary / infrastructure

This repository documents the steps required to set up a fresh RecipeRadar environment
GNU Affero General Public License v3.0
5 stars 5 forks source link

RFC9239: Update MIME type within content-type response headers for JavaScript content #33

Closed jayaddison closed 2 years ago

jayaddison commented 2 years ago

Describe the reason for these changes and the problem that they solve

<script type="text/javascript" ... and Content-Type: application/javascript are both MIME types that are widely read and understood intuitively. It seems like RFC9239 makes an attempt to address a technical/specification inconsistency between the two of them.

In particular, section six of RFC9239 ("IANA Considerations") states:

The media type registrations herein are divided into two major categories: (1) the sole media type "text/javascript", which is now in common usage and (2) all of the media types that are obsolete (i.e., "application/ecmascript", "application/javascript", "application/x-ecmascript", "application/x-javascript", "text/ecmascript", "text/javascript1.0", "text/javascript1.1", "text/javascript1.2", "text/javascript1.3", "text/javascript1.4", "text/javascript1.5", "text/jscript", "text/livescript", and "text/x-ecmascript").

Briefly summarize the changes

  1. When handling outbound responses from the frontend application, if the Content-Type header matches the application/javascript MIME type, perform a string replacement at the start of the header to replace application/javascript with text/javascript.

How have the changes been tested?

  1. Deployed to an haproxy instance and tested with some example requests to an instance of the frontend application