更改 Okhttp RequestBody 表单值
Change Okhttp RequestBody form value
我想更改Okhttp中的RequestBody,RequestBody的方法是POST形式。
但是,我不知道如何将 RequestBody 更改为 Form 或 map。(//TODO in the following)
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
并将其转换为文本,并与现有表单连接,也转换为文本,然后提交。
我想更改Okhttp中的RequestBody,RequestBody的方法是POST形式。
但是,我不知道如何将 RequestBody 更改为 Form 或 map。(//TODO in the following)
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
并将其转换为文本,并与现有表单连接,也转换为文本,然后提交。