add nullpointer protection for contentEncoding