We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
i use com.squareup.okhttp:okhttp:2.5.0 , com.squareup.retrofit:retrofit:1.9.0 // okhttpclient setting OkHttpClient statisticsApiClient = new OkHttpClient(); statisticsApiClient.setReadTimeout(20000, TimeUnit.MILLISECONDS); statisticsApiClient.setConnectTimeout(20000, TimeUnit.MILLISECONDS); statisticsApiClient.interceptors().add(new GzipRequestInterceptor()); RestAdapter restStatisticsAdapter = new RestAdapter.Builder().setEndpoint("http://test.couchgram.com").setClient(new OkClient(statisticsApiClient)) .setLogLevel(RestAdapter.LogLevel.FULL).build(); statisticsService = restStatisticsAdapter.create(RequestService.class); // rest api @Headers("Cache-Control: max-age=5000") @POST("/api/v1/log") @FormUrlEncoded Observable<NewBaseData> postStatisticsData(@Field(ServerConst.STATISTICS_DATA) String statistics_data); // gzip public class GzipRequestInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { return chain.proceed(originalRequest); } Request compressedRequest = originalRequest.newBuilder() .header("Content-Encoding", "gzip") .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) .build(); return chain.proceed(compressedRequest); } /** https://github.com/square/okhttp/issues/350 */ private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { final Buffer buffer = new Buffer(); requestBody.writeTo(buffer); return new RequestBody() { @Override public MediaType contentType() { return requestBody.contentType(); } @Override public long contentLength() { return buffer.size(); } @Override public void writeTo(BufferedSink sink) throws IOException { sink.write(buffer.snapshot()); } }; } private RequestBody gzip(final RequestBody body) { return new RequestBody() { @Override public MediaType contentType() { return body.contentType(); } @Override public long contentLength() { return -1; // We don't know the compressed length in advance! } @Override public void writeTo(BufferedSink sink) throws IOException { BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); body.writeTo(gzipSink); gzipSink.close(); } }; } } HTTP 416 error
The text was updated successfully, but these errors were encountered:
416 = Requested Range not satisfiable the server is looking to right amount of bytes to match. If it is not, you get 416 error.
Sorry, something went wrong.
ok sorry T_T server check
No branches or pull requests
The text was updated successfully, but these errors were encountered: