You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2006/06/06 10:50:08 UTC

svn commit: r412047 - in /jakarta/commons/proper/httpclient/trunk/src: java/org/apache/commons/httpclient/methods/ test/org/apache/commons/httpclient/ test/org/apache/commons/httpclient/auth/

Author: olegk
Date: Tue Jun  6 01:50:08 2006
New Revision: 412047

URL: http://svn.apache.org/viewvc?rev=412047&view=rev
Log:
[HTTPCLIENT-536] misleading lack of javadoc in StringRequestEntity

Contributed by Oleg Kalnichevski
Reviewed by Roland Weber

Modified:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEntityEnclosingMethod.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoncompliant.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostMethod.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostParameterEncoding.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestRedirects.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/auth/TestBasicAuth.java

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java Tue Jun  6 01:50:08 2006
@@ -189,8 +189,11 @@
                 if (LOG.isWarnEnabled()) {
                     LOG.warn(charset + " not supported");
                 }
-                this.requestEntity = new StringRequestEntity(
-                        requestString);
+                try {
+                    this.requestEntity = new StringRequestEntity(
+                            requestString, null, null);
+                } catch (UnsupportedEncodingException ignore) {
+                }
             }
         }
 

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java Tue Jun  6 01:50:08 2006
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java,v 1.3 2004/07/03 14:27:03 olegk Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -58,16 +58,11 @@
      * will use the default platform charset to convert the content string 
      * and will provide no content type.</p>
      *  
-     * <p>This constructor may be deprecated or changed to use the 
-     * default HTTP content charset (ISO-8859-1) in the release 3.1</p>
-     * 
-     * <p>It is strongly recommended to use 
-     * {@link #StringRequestEntity(String, String, String)} constructor 
-     * instead.</p>
-     * 
      * @see #StringRequestEntity(String, String, String)
      * 
      * @param content The content to set.
+     * 
+     * @deprecated use {@link #StringRequestEntity(String, String, String)} instead
      */
     public StringRequestEntity(String content) {
         super();

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java Tue Jun  6 01:50:08 2006
@@ -78,7 +78,7 @@
         this.client.setHttpConnectionManager(connman);
         
         PostMethod httppost = new PostMethod("/test/");
-        httppost.setRequestEntity(new StringRequestEntity("stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {
@@ -87,7 +87,7 @@
         assertFalse(connman.getConection().isOpen());
 
         httppost = new PostMethod("/test/");
-        httppost.setRequestEntity(new StringRequestEntity("more stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("more stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {
@@ -105,7 +105,7 @@
         this.client.setHttpConnectionManager(connman);
         
         PostMethod httppost = new PostMethod("/test/");
-        httppost.setRequestEntity(new StringRequestEntity("stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {
@@ -114,7 +114,7 @@
         assertTrue(connman.getConection().isOpen());
 
         httppost = new PostMethod("/test/");
-        httppost.setRequestEntity(new StringRequestEntity("more stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("more stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {
@@ -132,7 +132,7 @@
         this.client.setHttpConnectionManager(connman);
         
         PostMethod httppost = new PostMethod("/test/");
-        httppost.setRequestEntity(new StringRequestEntity("stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {
@@ -142,7 +142,7 @@
 
         httppost = new PostMethod("/test/");
         httppost.setRequestHeader("Connection", "close");
-        httppost.setRequestEntity(new StringRequestEntity("more stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("more stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {
@@ -160,7 +160,7 @@
         this.client.setHttpConnectionManager(connman);
         
         PostMethod httppost = new PostMethod("/test/");
-        httppost.setRequestEntity(new StringRequestEntity("stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {
@@ -170,7 +170,7 @@
 
         httppost = new PostMethod("/test/");
         httppost.setRequestHeader("Connection", "keep-alive");
-        httppost.setRequestEntity(new StringRequestEntity("more stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("more stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {
@@ -208,7 +208,7 @@
         
         PostMethod httppost = new PostMethod("/test/");
         httppost.setRequestHeader("Connection", "close");
-        httppost.setRequestEntity(new StringRequestEntity("stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("stuff", null, null));
         try {
             this.client.executeMethod(httppost);
         } finally {

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEntityEnclosingMethod.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEntityEnclosingMethod.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEntityEnclosingMethod.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestEntityEnclosingMethod.java Tue Jun  6 01:50:08 2006
@@ -323,7 +323,7 @@
 
         method = new PostMethod("/");
         method.setRequestHeader("Content-Type", "text/plain");
-        method.setRequestEntity(new StringRequestEntity(""));
+        method.setRequestEntity(new StringRequestEntity("", null, null));
 		this.client.executeMethod(method);
         assertEquals(200,method.getStatusLine().getStatusCode());
         assertNotNull(method.getRequestHeader("Content-Length"));
@@ -341,7 +341,7 @@
 
         method = new PostMethod("/");
         method.setRequestHeader("Content-Type", "text/plain");
-        method.setRequestEntity(new StringRequestEntity(""));
+        method.setRequestEntity(new StringRequestEntity("", null, null));
         method.setContentChunked(true);
 		this.client.executeMethod(method);
         assertNull(method.getRequestHeader("Content-Length"));

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoncompliant.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoncompliant.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoncompliant.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoncompliant.java Tue Jun  6 01:50:08 2006
@@ -77,7 +77,7 @@
         method.getParams().setBooleanParameter(
                 HttpMethodParams.USE_EXPECT_CONTINUE, true);
         method.setRequestEntity(new StringRequestEntity(
-                "This is data to be sent in the body of an HTTP POST."));
+                "This is data to be sent in the body of an HTTP POST.", null, null));
         client.executeMethod(method);
         assertEquals(200, method.getStatusCode());
     }

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostMethod.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostMethod.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostMethod.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostMethod.java Tue Jun  6 01:50:08 2006
@@ -105,7 +105,7 @@
         PostMethod method = new PostMethod("/");
         String stringBody = "pname1=pvalue1&pname2=pvalue2";
 
-        method.setRequestEntity(new StringRequestEntity(stringBody));
+        method.setRequestEntity(new StringRequestEntity(stringBody, null, null));
         this.server.setHttpService(new EchoService());
         try {
             this.client.executeMethod(method);

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostParameterEncoding.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostParameterEncoding.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostParameterEncoding.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestPostParameterEncoding.java Tue Jun  6 01:50:08 2006
@@ -100,7 +100,7 @@
     public void testPostSetRequestBody() throws Exception {
         PostMethod post = new PostMethod("/foo");
         String body = "this+is+the+body";
-        post.setRequestEntity(new StringRequestEntity(body));
+        post.setRequestEntity(new StringRequestEntity(body, null, null));
         assertEquals(body, getRequestAsString(post.getRequestEntity()));
     }
     

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java Tue Jun  6 01:50:08 2006
@@ -438,7 +438,7 @@
     public void testSimplePost() throws Exception {
         this.server.setHttpService(new FeedbackService());
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -464,7 +464,7 @@
         this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -490,7 +490,7 @@
         this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -520,7 +520,7 @@
         this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_UNAUTHORIZED, post.getStatusCode());
@@ -546,7 +546,7 @@
         this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -573,7 +573,7 @@
         this.server.setRequestHandler(handlerchain);
         
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -596,7 +596,7 @@
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -625,7 +625,7 @@
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -654,7 +654,7 @@
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -686,7 +686,7 @@
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_UNAUTHORIZED, post.getStatusCode());
@@ -714,7 +714,7 @@
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());
@@ -743,7 +743,7 @@
         this.proxy.requireAuthentication(creds, "test", true);
 
         PostMethod post = new PostMethod("/");
-        post.setRequestEntity(new StringRequestEntity("Like tons of stuff"));
+        post.setRequestEntity(new StringRequestEntity("Like tons of stuff", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals(HttpStatus.SC_OK, post.getStatusCode());

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestRedirects.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestRedirects.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestRedirects.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestRedirects.java Tue Jun  6 01:50:08 2006
@@ -361,7 +361,7 @@
         int port = this.server.getLocalPort();
         this.server.setHttpService(new BasicRedirectService(host, port));
         PostMethod httppost = new PostMethod("/oldlocation/");
-        httppost.setRequestEntity(new StringRequestEntity("stuff"));
+        httppost.setRequestEntity(new StringRequestEntity("stuff", null, null));
         try {
             this.client.executeMethod(httppost);
             assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, httppost.getStatusCode());

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/auth/TestBasicAuth.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/auth/TestBasicAuth.java?rev=412047&r1=412046&r2=412047&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/auth/TestBasicAuth.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/auth/TestBasicAuth.java Tue Jun  6 01:50:08 2006
@@ -492,7 +492,7 @@
         this.server.setRequestHandler(handlerchain);
 
         PostMethod post = new PostMethod("/test/");
-        post.setRequestEntity(new StringRequestEntity("Test body"));
+        post.setRequestEntity(new StringRequestEntity("Test body", null, null));
         try {
             this.client.executeMethod(post);
             assertEquals("Test body", post.getResponseBodyAsString());
@@ -531,7 +531,7 @@
         this.server.setRequestHandler(handlerchain);
 
         PutMethod put = new PutMethod("/test/");
-        put.setRequestEntity(new StringRequestEntity("Test body"));
+        put.setRequestEntity(new StringRequestEntity("Test body", null, null));
         try {
             this.client.executeMethod(put);
             assertEquals("Test body", put.getResponseBodyAsString());



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