Doesn't appear to be a way to stream a Response directly to disk. Maybe this is not in Retrofit's wheelhouse, but I have a call that retrieves Zip files that are large and with a normal sized heap Retrofit OOMEs as it spools everything into memory first before making it available to userspace.
Version 1.6 added @Streaming for the Response type which hands you the raw InputStream regardless of your log level. If you don't have logging enabled (LogLevel.NONE, the default) we should also be handing you the raw InputStream regardless of the presence of the annotation.
I can look more into this tomorrow or Friday.
Thanks for the Response! (pun intended :-))
I'll upgrade to 1.6 and give it a whirl.
Streaming is happy, thanks!
Excellent!
Hi, could Retrofit ignore HttpLoggingInterceptor when using @Streaming?
I found it can not be achieved.
N. They don't know about each other.
On Mon, Dec 7, 2015, 4:36 AM Jie [email protected] wrote:
Hi, could Retrofit ignore HttpLoggingInterceptor when using @Streaming?
I found it can not be achieved.—
Reply to this email directly or view it on GitHub
https://github.com/square/retrofit/issues/568#issuecomment-162463887.
@initialjie
Have you found any solutions to avoid logging of streaming? I added the following as a workaround:
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
boolean skipBody = false;
@Override public void log(String message) {
if( message.contains("Content-type: application/pdf") )
skipBody = true;
if( message.length() > 5000 && skipBody ) {
skipBody = false;
return;
}
Timber.tag("OkHttp").d(message);
}
});
@tentypwtk
Sorry for replying it just now.
Thanks for your suggestion!
Whether it is a wonderfully solution for just a few particular assumption(If)?
How can we do this in OkHttp same as @Streaming without using Retrofit?
OkHttp is always streaming.
Most helpful comment
@initialjie
Have you found any solutions to avoid logging of streaming? I added the following as a workaround:
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {boolean skipBody = false;@Override public void log(String message) {if( message.contains("Content-type: application/pdf") )skipBody = true;if( message.length() > 5000 && skipBody ) {skipBody = false;return;}Timber.tag("OkHttp").d(message);}});