AWS Cloudfront function: Content-Type Filter

 var allow_content_type = {
     "image/jpeg": true,
     "video/mp4": true,
     "binary/octet-stream": true,
     "application/octet-stream": true,
 };

var response = function(t) {
    return {
        statusCode: 403,
        statusDescription: 'Forbidden',
        headers: {
            'content-type': { value: t},
        }
    };
};

function handler(event) {
    if (event.request.method != "PUT") {
        return event.request;
    }
   
    if (!event.request.headers['content-type']) {
        return response("empty");
    } else if !allow_content_type[event.request.headers['content-type'].value]) {
        return response(event.request.headers['content-type'].value);
    }
    
    return request;
}