2016-09-28 2 views
2

Ich benutze Retrofit2, um Android App zu entwickeln. Mit gzip stimmt etwas nicht und hier ist der Ausnahme-Stack. Ich weiß nicht, wo genau die Ausnahme passiert. Jeder Rat wird geschätzt. Vielen Dank.Android Retrofit 2 gzip Fehler

Unknown exception 
java.io.EOFException 
    at okio.RealBufferedSource.require(RealBufferedSource.java:64) 
    at okio.GzipSource.consumeHeader(GzipSource.java:114) 
    at okio.GzipSource.read(GzipSource.java:73) 
    at okio.RealBufferedSource.request(RealBufferedSource.java:71) 
    at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:225) 
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187) 
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160) 
    at okhttp3.RealCall.execute(RealCall.java:57) 
    at retrofit2.OkHttpCall.execute(OkHttpCall.java:174) 
    at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:89) 
    at com.hello.de.aloha.domain.interactor.RetrofitServerInteraction.callVerifyOauthToken(RetrofitServerInteraction.java:424) 
    at com.hello.de.aloha.domain.security.SecurityHandshake.validateOAuthToken(SecurityHandshake.java:178) 
    at com.hello.de.aloha.domain.security.SecurityHandshake.requestOAuthToken(SecurityHandshake.java:150) 
    at com.hello.de.aloha.domain.security.SecurityHandshake.authenticate(SecurityHandshake.java:122) 
    at com.hello.de.aloha.domain.security.SecurityHandshake.challenge(SecurityHandshake.java:70) 
    at com.hello.de.aloha.domain.interceptor.SecurityInterceptor.determineNewToken(SecurityInterceptor.java:152) 
    at com.hello.de.aloha.domain.interceptor.SecurityInterceptor.intercept(SecurityInterceptor.java:89) 
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187) 
    at com.hello.de.aloha.domain.interceptor.SendCookieInterceptor.intercept(SendCookieInterceptor.java:46) 
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187) 
    at com.hello.de.aloha.domain.interceptor.ReceiveCookiesInterceptor.intercept(ReceiveCookiesInterceptor.java:43) 
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187) 
    at com.hello.de.aloha.domain.interceptor.HttpParamInterceptor.intercept(HttpParamInterceptor.java:75) 
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187) 
    at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:203) 
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187) 
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160) 
    at okhttp3.RealCall.access$100(RealCall.java:30) 
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127) 
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
    at java.lang.Thread.run(Thread.java:818) 
+0

Konnten Sie Ihnen Methode bekannt geben, die Sie Retrofit verwenden? –

Antwort

2

Ich habe den Code in GzipSource geprüft:

private void consumeHeader() throws IOException { 
     // Read the 10-byte header. We peek at the flags byte first so we know if we 
     // need to CRC the entire header. Then we read the magic ID1ID2 sequence. 
     // We can skip everything else in the first 10 bytes. 
     // +---+---+---+---+---+---+---+---+---+---+ 
     // |ID1|ID2|CM |FLG|  MTIME  |XFL|OS | (more-->) 
     // +---+---+---+---+---+---+---+---+---+---+ 
     source.require(10); 
     ... 
    } 
@Override public void require(long byteCount) throws IOException { 
    if (!request(byteCount)) throw new EOFException(); 
    } 

    @Override public boolean request(long byteCount) throws IOException { 
    if (byteCount < 0) throw new IllegalArgumentException("byteCount < 0: " + byteCount); 
    if (closed) throw new IllegalStateException("closed"); 
    while (buffer.size < byteCount) { 
     if (source.read(buffer, Segment.SIZE) == -1) return false; 
    } 
    return true; 
    } 

Es scheint, dass Ihre Antwortdaten das Format gzip verletzt. Es empfiehlt sich daher, zuerst die Antwortdaten zu überprüfen. Möglicherweise müssen Sie auch den Header der Anfrage überprüfen, den Sie übergeben haben und der sich auf das Format der Antwortdaten auswirkt (z. B. accept: gzip).