// File
else if(type.equals("file")) {
hasForm=true;
if(this.method==METHOD_GET) throw new ApplicationException("httpparam type file can't only be used, when method of the tag http equal post");
String strCT = getContentType(param);
ContentType ct = HTTPUtil.toContentType(strCT,null);
String mt="text/xml";
if(ct!=null && !StringUtil.isEmpty(ct.getMimeType(),true)) mt=ct.getMimeType();
String cs=charset;
if(ct!=null && !StringUtil.isEmpty(ct.getCharset(),true)) cs=ct.getCharset();
if(doMultiPart) {
try {
Resource res = param.getFile();
parts.add(new FormBodyPart(
param.getName(),
new ResourceBody(res, mt, res.getName(), cs)
));
//parts.add(new ResourcePart(param.getName(),new ResourcePartSource(param.getFile()),getContentType(param),_charset));
}
catch (FileNotFoundException e) {
throw new ApplicationException("can't upload file, path is invalid",e.getMessage());
}
}
}
// XML
else if(type.equals("xml")) {
ContentType ct = HTTPUtil.toContentType(param.getMimeType(),null);
String mt="text/xml";
if(ct!=null && !StringUtil.isEmpty(ct.getMimeType(),true)) mt=ct.getMimeType();
String cs=charset;
if(ct!=null && !StringUtil.isEmpty(ct.getCharset(),true)) cs=ct.getCharset();
hasBody=true;
hasContentType=true;
req.addHeader("Content-type", mt+"; charset="+cs);
if(eem==null)throw new ApplicationException("type xml is only supported for type post and put");
HTTPEngine4Impl.setBody(eem, param.getValueAsString(),mt,cs);
}
// Body
else if(type.equals("body")) {
ContentType ct = HTTPUtil.toContentType(param.getMimeType(),null);
String mt=null;
if(ct!=null && !StringUtil.isEmpty(ct.getMimeType(),true)) mt=ct.getMimeType();
String cs=charset;
if(ct!=null && !StringUtil.isEmpty(ct.getCharset(),true)) cs=ct.getCharset();
hasBody=true;
if(eem==null)throw new ApplicationException("type body is only supported for type post and put");
HTTPEngine4Impl.setBody(eem, param.getValue(),mt,cs);