Skip to content
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

Closed
reisub opened this issue Mar 17, 2017 · 4 comments
Closed

Logging interceptor breaks downloading pdf file #14

reisub opened this issue Mar 17, 2017 · 4 comments
Assignees
Labels

Comments

@reisub
Copy link
Collaborator

reisub commented Mar 17, 2017

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 is application/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.

@ihsanbal ihsanbal self-assigned this Mar 17, 2017
@ihsanbal ihsanbal added the bug label Mar 17, 2017
@ihsanbal
Copy link
Owner

@reisub Thanks for your help! I will fix this two bug as soon as possible.

@ihsanbal ihsanbal added this to the 1.0.6 milestone Mar 18, 2017
ihsanbal added a commit that referenced this issue Mar 18, 2017
@ihsanbal
Copy link
Owner

ihsanbal commented Mar 18, 2017

@reisub Release candidate available with 1.0-rc6 tag. Can you check and close issue please.

@reisub
Copy link
Collaborator Author

reisub commented Mar 20, 2017

Verified as working.

@reisub reisub closed this as completed Mar 20, 2017
@ihsanbal ihsanbal reopened this Mar 20, 2017
@ihsanbal
Copy link
Owner

@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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants