Body decoding

Hello All,

Am I correct that nginx does not decode server response, and in the
case of sub_filter it tries to operate on encoded content?
(There are two encodings I’m aware of - Content-Encoding and
Transport-Encoding.)

If no, what are the configuration steps to decode body before
sub_filter?

If yes, what can impede me in creating my own decoding filter - are
there any architectural constraints, did anyone try that?