Fixed the ranking of matching mediaTypes to header parts. Also added quick exit if empty input.