This chunk of code does quite a lot of stuff that has a distinct purpose. It should be a separate function that takes res.headers as an argument and returns the assetType.