Я думаю, вы можете попробовать ОхТПП вместо apache .
build.gradle
dependencies {
...
implementation "com.squareup.okhttp3:okhttp:4.2.1"
}
ResponseInterceptor.java
public class ResponseInterceptor implements Interceptor {
@NotNull
@Override
public Response intercept(@NotNull Chain chain) throws IOException {
Response response = chain.proceed(chain.request());
Response modifiedResponse =
response.networkResponse().newBuilder()
.addHeader("Content-Type", "application/json; charset=utf-8")
.build();
return modifiedResponse;
}
}
Использование
OkHttpClient client = new OkHttpClient.Builder()
.......
.addInterceptor(new ResponseInterceptor())
.build();