use of com.lidroid.xutils.http.client.entity.BodyParamsEntity in project xUtils by wyouflf.
the class RequestParams method getEntity.
/**
* Returns an HttpEntity containing all request parameters
*/
public HttpEntity getEntity() {
if (bodyEntity != null) {
return bodyEntity;
}
HttpEntity result = null;
if (fileParams != null && !fileParams.isEmpty()) {
MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.STRICT, null, Charset.forName(charset));
if (bodyParams != null && !bodyParams.isEmpty()) {
for (NameValuePair param : bodyParams) {
try {
multipartEntity.addPart(param.getName(), new StringBody(param.getValue()));
} catch (UnsupportedEncodingException e) {
LogUtils.e(e.getMessage(), e);
}
}
}
for (ConcurrentHashMap.Entry<String, ContentBody> entry : fileParams.entrySet()) {
multipartEntity.addPart(entry.getKey(), entry.getValue());
}
result = multipartEntity;
} else if (bodyParams != null && !bodyParams.isEmpty()) {
result = new BodyParamsEntity(bodyParams, charset);
}
return result;
}
Aggregations