-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deflate as a supported REST response encoding
Some HTTP servers don't parse Accept-Encoding headers as they should and just assume that deflate is commonly available. okhttp3 has built-in support for transparently adding gzip as an accepted encoding, and decoding the response body, which is how gzip previously Just Worked. This built-in encoding handler is conditional on the user not passing in any Accept-Encoding headers, which is assumed to indicate that the caller intends to somehow handle the encoded response body themself. We can implement our own transparent decoding support using the same mechanism that okhttp3 does internally and add an Interceptor callback that adds headers before the request and returns a new response with the encoding headers removed and the body wrapped in decoding readers. This is strictly more correct than the okhttp3 built-in decoder because Content-Encoding can be a sequence of encodings applied in order that have to be decoded in reverse order.
- Loading branch information
1 parent
c5c1f62
commit 61307e0
Showing
1 changed file
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters