Improve performance of mimetype guessing when we use the file extension.

Review Request #13513 — Created Jan. 31, 2024 and submitted — Latest diff uploaded

Information

Review Board
master

Reviewers

A while back we added an escape hatch for mapping certain file
extensions to mimetypes for when mimeparse messes up (specfically with
text/x-rst and text/x-markdown). While I was looking at this code, I
realized that we go through all the trouble of using mimeparse only to
throw away the result. The mimeparse code isn't doing a whole lot, but
it's always better to avoid doing work if we don't need to. This change
swaps those so if we're going to match based on the file extension, we
do that first, and only use mimeparse otherwise.

Ran unit tests.

Commits

Files

    Loading...