Encode with gzip only if a session exists
Since 1923117e935d the server does not accept compressed content for unauthenticated request.
This was found when investigating #13203 (closed) but it seems that the client does not make unauthenticated request that exceed the threshold.