-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging interceptor breaks downloading pdf file #14
Labels
Comments
@reisub Thanks for your help! I will fix this two bug as soon as possible. |
Verified as working. |
@reisub I reopened this issue for check content-type is null or not. |
ihsanbal
added a commit
that referenced
this issue
Mar 20, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this interceptor breaks pdf download for me.
The usage is simple, I have a direct link to a pdf file which I download with Retrofit and write into a file. The original pdf has around 199kb, however the downloaded file has around 350kb.
I debugged into the issue and I think the problem is in this line:
https://github.com/ihsanbal/LoggingInterceptor/blob/master/library/src/main/java/com/ihsanbal/logging/LoggingInterceptor.java#L70
This line sets the response body content type to the same content type that the request body has which is not correct behavior. In this case, the request body is
application/json
and the response body isapplication/pdf
. As a result, the pdf gets downloaded with the wrong encoding and it results in a corrupt file.Another problem I see is that the interceptor will reformat the body before passing it on which is just asking for problems. The interceptor should pass the original body down the interceptor chain and reformat just for display. It doesn't even check the content type to see if the body is in fact json.
The text was updated successfully, but these errors were encountered: