Fix the Content-Encoding Header when EnableGzip is true.

The WriteHeader method of the "recorder" middleware was called before the
Write method of the "gzip" middleware.

For safety, all Headers should be set in WriteHeader methods.

Also, added a test to check the Content-Encoding of error responses.