2
我想要更改Okhttp中的RequestBody,RequestBody的方法是POST表單。更改Okhttp RequestBody表單值
但是,我不知道如何改變RequestBody到窗體或地圖。(在後續// TODO)
httpClient.networkInterceptors().add(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
RequestBody body = original.body();
if (null != body) {
//TODO Get the form data, encrypt the value of 'data', and add a param with version/1.0
body = new EncryptRequestBody(body);
}
Request.Builder requestBuilder = original.newBuilder()
.method(original.method(), body);
Request request = requestBuilder.build();
return chain.proceed(request);
}
});
FormBody.Builder是否工作? http://square.github.io/okhttp/3.x/okhttp/index.html?okhttp3/FormBody.Builder.html –
我使用了2.x,並且想將原始的RequestBody更改爲一張地圖,然後更改一些在地圖中,不會創建一個新的RequestBody。我不知道如何從RequestBody對象中挑選出鍵和值。 – Pitty