correctly handle accept encoding gzip

fixes issue #1983

I hope the place I moved the parsing method to is acceptable.