commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r410848 - /jakarta/commons/proper/httpclient/trunk/src/examples/PostXML.java
Date Thu, 01 Jun 2006 11:57:39 GMT
Author: olegk
Date: Thu Jun  1 04:57:39 2006
New Revision: 410848

URL: http://svn.apache.org/viewvc?rev=410848&view=rev
Log:
Replaced InputStreamRequestEntity with repeatable FileRequestEntity

Modified:
    jakarta/commons/proper/httpclient/trunk/src/examples/PostXML.java

Modified: jakarta/commons/proper/httpclient/trunk/src/examples/PostXML.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/examples/PostXML.java?rev=410848&r1=410847&r2=410848&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/examples/PostXML.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/examples/PostXML.java Thu Jun  1 04:57:39
2006
@@ -29,11 +29,11 @@
  */
 
 import java.io.File;
-import java.io.FileInputStream;
 
 import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.methods.FileRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
 
 /**
  *
@@ -44,7 +44,7 @@
  * to a remote web server using HTTP POST
  *
  * @author Sean C. Sullivan
- * @author Ortwin Gl├╝ck
+ * @author Ortwin Glueck
  * @author Oleg Kalnichevski
  */
 public class PostXML {
@@ -76,18 +76,10 @@
         File input = new File(strXMLFilename);
         // Prepare HTTP post
         PostMethod post = new PostMethod(strURL);
-        // Request content will be retrieved directly 
+        // Request content will be retrieved directly
         // from the input stream
-        // Per default, the request content needs to be buffered
-        // in order to determine its length.
-        // Request body buffering can be avoided when
-        // content length is explicitly specified
-        post.setRequestEntity(new InputStreamRequestEntity(
-            new FileInputStream(input), input.length()));
-        // Specify content type and encoding
-        // If content encoding is not explicitly specified
-        // ISO-8859-1 is assumed
-        post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
+        RequestEntity entity = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1");
+        post.setRequestEntity(entity);
         // Get HTTP client
         HttpClient httpclient = new HttpClient();
         // Execute request



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message