--- httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java 2010-11-30 22:26:02.000000000 +0000 +++ httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java 2010-11-30 20:14:12.000000000 +0000 @@ -49,32 +49,29 @@ System.exit(1); } HttpClient httpclient = new DefaultHttpClient(); - try { - HttpPost httppost = new HttpPost("http://localhost:8080" + - "/servlets-examples/servlet/RequestInfoExample"); - - FileBody bin = new FileBody(new File(args[0])); - StringBody comment = new StringBody("A binary file of some kind"); - - MultipartEntity reqEntity = new MultipartEntity(); - reqEntity.addPart("bin", bin); - reqEntity.addPart("comment", comment); - - httppost.setEntity(reqEntity); - - System.out.println("executing request " + httppost.getRequestLine()); - HttpResponse response = httpclient.execute(httppost); - HttpEntity resEntity = response.getEntity(); - - System.out.println("----------------------------------------"); - System.out.println(response.getStatusLine()); - if (resEntity != null) { - System.out.println("Response content length: " + resEntity.getContentLength()); - } - EntityUtils.consume(resEntity); - } finally { - try { httpclient.getConnectionManager().shutdown(); } catch (Exception ignore) {} + + HttpPost httppost = new HttpPost("http://localhost:8080" + + "/servlets-examples/servlet/RequestInfoExample"); + + FileBody bin = new FileBody(new File(args[0])); + StringBody comment = new StringBody("A binary file of some kind"); + + MultipartEntity reqEntity = new MultipartEntity(); + reqEntity.addPart("bin", bin); + reqEntity.addPart("comment", comment); + + httppost.setEntity(reqEntity); + + System.out.println("executing request " + httppost.getRequestLine()); + HttpResponse response = httpclient.execute(httppost); + HttpEntity resEntity = response.getEntity(); + + System.out.println("----------------------------------------"); + System.out.println(response.getStatusLine()); + if (resEntity != null) { + System.out.println("Response content length: " + resEntity.getContentLength()); } + EntityUtils.consume(resEntity); } }