harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r957725 - in /harmony/enhanced/java/trunk/classlib/modules/luni/src: main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
Date Thu, 24 Jun 2010 21:39:36 GMT
Author: hindessm
Date: Thu Jun 24 21:39:35 2010
New Revision: 957725

URL: http://svn.apache.org/viewvc?rev=957725&view=rev
Log:
Applied patch from "[#HARMONY-6536] [classlib][luni] HttpOutputStream.write()
need throw IOException only when fixed mode is set to true".

Modified:
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
    harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java?rev=957725&r1=957724&r2=957725&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
Thu Jun 24 21:39:35 2010
@@ -493,7 +493,7 @@ public class HttpURLConnectionImpl exten
             }
 
             if (limit >= 0) {
-                if (count > limit) {
+                if (count > limit && fixedMod) {
                     throw new IOException(Messages.getString("luni.26")); //$NON-NLS-1$
                 }
                 limit -= count;

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java?rev=957725&r1=957724&r2=957725&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
Thu Jun 24 21:39:35 2010
@@ -337,13 +337,29 @@ public class HttpURLConnectionTest exten
 
         OutputStream out = conn.getOutputStream();
         out.write(posted.getBytes());
+        //should not throw IOExeption
+        out.close();
+    }
+    
+    /**
+     * When write bytes to HttpOutputSteam, only if fixed mode is true and the write number
of bytes is
+     * greater than the limit of HttpOutputStream, the write method will throw IOException
+     * @throws IOException
+     */
+    public void test_writeWithFixedLengthDisableMode() throws IOException {
+        String bigString = "big String:/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
b/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java";
+        System.out.println(bigString.length());
 
-        try {
-            out.close();
-            // expected
-        } catch (IOException e) {
-            fail("should not throw IOException");
-        }
+        java.net.HttpURLConnection httpURLConnection = (HttpURLConnection) url
+                .openConnection();
+
+        httpURLConnection.setDoOutput(true);
+        httpURLConnection.setRequestMethod("POST");
+        httpURLConnection.setRequestProperty("Content-Length", "" + (168));
+
+        OutputStream out = httpURLConnection.getOutputStream();
+        //should not throw IOExeption
+        out.write(bigString.getBytes());
     }
 
     /**



Mime
View raw message