NYPL-Simplified / server_core

Shared data model and utilities for Library Simplified server applications
7 stars 11 forks source link

For URLs, use only path component to guess content type. #1192

Closed tdilauro closed 4 years ago

tdilauro commented 4 years ago

Description

This branch adds a method that uses only the path component of a URL when attempting to guess the content type based on the "file" extension inferred from URL. Also updated some code where a simpler method meant for files was being used for URLs.

Motivation and Context

URLs with query strings don't end with a type-hinting "file" extension that can help us guess at the associated content type. Unless we base our guess on the URL's path, we can end up failing to guess or even being mislead by the end of the query string.

How Has This Been Tested?

Checklist:

tdilauro commented 4 years ago

This is ready to merge, if you're good with the additional tests.