You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/09/18 00:50:27 UTC

DO NOT REPLY [Bug 12752] New: - [PATCH] Remove use of deprecated o.a.c.httpclient.methods.PostMethod.setRequestBody ( String )

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12752>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12752

[PATCH] Remove use of deprecated o.a.c.httpclient.methods.PostMethod.setRequestBody ( String )

           Summary: [PATCH] Remove use of deprecated
                    o.a.c.httpclient.methods.PostMethod.setRequestBody (
                    String )
           Product: Commons
           Version: Nightly Builds
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Latka
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: janekdb@yahoo.co.uk


This patch changes the use of PostMethod.setRequestBody ( String ) to
PostMethod.setRequestBody ( InputStream ). The first method is deprecated in the
the CVS version of httpclient.


Index: RequestImpl.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java,v
retrieving revision 1.29
diff -u -r1.29 RequestImpl.java
--- RequestImpl.java	4 Sep 2002 02:59:26 -0000	1.29
+++ RequestImpl.java	17 Sep 2002 22:37:46 -0000
@@ -61,6 +61,8 @@
 package org.apache.commons.latka.http;
 // java imports
 import java.net.URL;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.io.IOException;
 import java.util.List;
 // latka imports
@@ -263,7 +265,8 @@
         }

         if (_requestBody != null) {
-            ((PostMethod) _httpMethod).setRequestBody(_requestBody);
+            InputStream  is = new
ByteArrayInputStream(_requestBody.getBytes("UTF-16"));
+            ((PostMethod) _httpMethod).setRequestBody(is);
         } else {
             List parameters = _parameters.getParameters();
             for (int i = 0; i < parameters.size(); ++i) {

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>