ByteArrayEntity entity = new ByteArrayEntity(binary.getContent(), ContentType.parse(binary.getContentType()));
HttpRequestBase retVal = createRequest(url, entity);
return retVal;
}
IParser parser;
String contentType;
EncodingEnum encoding = null;
encoding = theEncoding;
if (encoding == EncodingEnum.JSON) {
parser = myContext.newJsonParser();
} else {
encoding = EncodingEnum.XML;
parser = myContext.newXmlParser();
}
AbstractHttpEntity entity;
if (myParams != null) {
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
for (Entry<String, List<String>> nextParam : myParams.entrySet()) {
parameters.add(new BasicNameValuePair(nextParam.getKey(), StringUtils.join(nextParam.getValue(), ',')));
}
try {
entity = new UrlEncodedFormEntity(parameters, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new InternalErrorException("Server does not support UTF-8 (should not happen)", e);
}
} else {
String contents;
if (myTagList != null) {
contents = parser.encodeTagListToString(myTagList);
contentType = encoding.getResourceContentType();
} else if (myBundle != null) {
contents = parser.encodeBundleToString(myBundle);
contentType = encoding.getBundleContentType();
} else if (myResources != null) {
Bundle bundle = RestfulServer.createBundleFromResourceList(myContext, "", myResources, "", "", myResources.size());
contents = parser.encodeBundleToString(bundle);
contentType = encoding.getBundleContentType();
} else if (myContents != null) {
contents = myContents;
if (myContentsIsBundle) {
contentType = encoding.getBundleContentType();
} else {
contentType = encoding.getResourceContentType();
}
} else {
contents = parser.encodeResourceToString(myResource);
contentType = encoding.getResourceContentType();
}
entity = new StringEntity(contents, ContentType.create(contentType, "UTF-8"));
}