trim media type value when doing comparisonand add null checks in http handler