X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FHttpClientUtils.java;h=229fa4ee9712e18cb8370a388f81708374ebcd2d;hb=7ab5d6b0ba5fec1ea4a4239e79c476d841622485;hp=93566f8d718f60e8b29fcce2d65181159491294a;hpb=1889827c44c51f6353fe8619e5d44b421158af23;p=jalview.git diff --git a/src/jalview/ws/HttpClientUtils.java b/src/jalview/ws/HttpClientUtils.java index 93566f8..229fa4e 100644 --- a/src/jalview/ws/HttpClientUtils.java +++ b/src/jalview/ws/HttpClientUtils.java @@ -43,8 +43,9 @@ import org.apache.http.impl.client.DefaultHttpClient; /** * Helpful procedures for working with services via HTTPClient + * * @author jimp - * + * */ public class HttpClientUtils { @@ -83,18 +84,20 @@ public class HttpClientUtils } public static BufferedReader doHttpMpartFilePost(String postUrl, - List vals, String fparm,File file, String mtype) throws ClientProtocolException, - IOException + List vals, String fparm, File file, String mtype) + throws ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(postUrl); - MultipartEntity mpe = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); - for (NameValuePair nvp:vals) + MultipartEntity mpe = new MultipartEntity( + HttpMultipartMode.BROWSER_COMPATIBLE); + for (NameValuePair nvp : vals) { mpe.addPart(nvp.getName(), new StringBody(nvp.getValue())); } - - FileBody fb = new FileBody(file, mtype!=null ? mtype : "application/octet-stream"); + + FileBody fb = new FileBody(file, mtype != null ? mtype + : "application/octet-stream"); mpe.addPart(fparm, fb); UrlEncodedFormEntity ue = new UrlEncodedFormEntity(vals, "UTF-8"); httppost.setEntity(ue); @@ -112,19 +115,22 @@ public class HttpClientUtils return null; } } + public static BufferedReader doHttpMpartInputstreamPost(String postUrl, - List vals, String fparm,String fname, InputStream is, String mtype) throws ClientProtocolException, + List vals, String fparm, String fname, + InputStream is, String mtype) throws ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(postUrl); MultipartEntity mpe = new MultipartEntity(HttpMultipartMode.STRICT); - for (NameValuePair nvp:vals) + for (NameValuePair nvp : vals) { mpe.addPart(nvp.getName(), new StringBody(nvp.getValue())); } - - InputStreamBody fb = (mtype!=null) ? new InputStreamBody(is, fname, mtype) : new InputStreamBody(is, fname); + + InputStreamBody fb = (mtype != null) ? new InputStreamBody(is, fname, + mtype) : new InputStreamBody(is, fname); mpe.addPart(fparm, fb); UrlEncodedFormEntity ue = new UrlEncodedFormEntity(vals, "UTF-8"); httppost.setEntity(ue);