use of pers.lizechao.android_lib.net.params.FormParams in project lzc_app_lib by httplzc.
the class OkHttpCallFactory method transToRequest.
private Request transToRequest(RequestData requestData) {
String url = requestData.url;
BaseParams params = requestData.params;
HttpMethod method = requestData.method;
HttpUrl httpUrl = HttpUrl.parse(url);
Objects.requireNonNull(httpUrl);
Request.Builder requestBuilder = new Request.Builder();
requestBuilder.headers(Headers.of(params.getHeads()));
RequestBody body = null;
if (method == HttpMethod.GET || method == HttpMethod.HEAD) {
if (!(params instanceof FormParams))
throw new IllegalArgumentException(method.name() + "只能为表单数据");
httpUrl = paramsToHttpUrl(httpUrl, (FormParams) params);
} else {
if (params instanceof RawParams) {
body = transToBody(((RawParams) params).getBinaryData());
} else if (params instanceof MultipartFormParams) {
body = transToBody((MultipartFormParams) params);
} else if (params instanceof FormParams) {
body = transToBody((FormParams) params);
}
}
if (body != null)
body = new ProxyRequestBody(body, requestData.uploadProgress);
return requestBuilder.url(httpUrl).method(method.name(), body).build();
}
use of pers.lizechao.android_lib.net.params.FormParams in project lzc_app_lib by httplzc.
the class ApiRequestCreater method createBaseParams.
private BaseParams createBaseParams(Object[] args, Params[] params, ParamsType paramsType) {
BaseParams.Builder builder = createParamsByType(paramsType);
FormParams comment = Optional.ofNullable(paramsBuilderFactory).map(ComParamsBuilderFactory::createBuilder).orElse(new FormParams.Builder().build());
if (paramsType != ParamsType.Raw) {
builder.putParams(comment);
}
builder.putBeanByData(args, params, new String[args.length]);
return builder.build();
}
Aggregations