MIME detection and add some error responses