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

How to resolve gzip response #1735

Closed
xiaoxie opened this issue Apr 12, 2016 · 1 comment
Closed

How to resolve gzip response #1735

xiaoxie opened this issue Apr 12, 2016 · 1 comment

Comments

@xiaoxie
Copy link

xiaoxie commented Apr 12, 2016

dear ,

My server needs to use gzip to optimize client data requests,
so i just test the demo SimpleService header:

public interface GitHub { @GET("/repos/{owner}/{repo}/contributors") @Headers("Accept-Encoding:gzip,deflate") Call<List<Contributor>> contributors( @Path("owner") String owner, @Path("repo") String repo); }

run demo throw an error

`request headers as follows:
header-->Accept-Encoding: gzip,deflate
Exception in thread "main" com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1566)
at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1416)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:597)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:429)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:74)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:116)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
at com.example.retrofit.SimpleService.main(SimpleService.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Process finished with exit code 1`

the problem is How to resolve gzip response ?

thanks .

@swankjesse
Copy link
Member

Remove the Accept-Encoding header. OkHttp will take care of gzip for you, but only if you aren't setting up gzip yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants