Optimize mimeType detection when no mimeType is specified

I think this addresses @simonster's concern in #262

Idk about the change to attachments.js. If it doesn't break anything, it would just prevent us from redoing the mimeType detection when the server does not supply a content type. Otherwise, this should probably be a fairly marginal case anyway and I'll remove that commit.