harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r407752 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java test/java/tests/api/java/net/HttpURLConnectionTest.java
Date Fri, 19 May 2006 09:01:47 GMT
Author: gharley
Date: Fri May 19 02:01:44 2006
New Revision: 407752

URL: http://svn.apache.org/viewvc?rev=407752&view=rev
Log:
HARMONY 472 : java.net.HttpURLConnection.getOutputStream will throw ProtocolException when
it's connected

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java?rev=407752&r1=407751&r2=407752&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
Fri May 19 02:01:44 2006
@@ -685,27 +685,34 @@
      * 
      */
     public OutputStream getOutputStream() throws IOException {
-        if (!doOutput)
+        if (!doOutput) {
             throw new ProtocolException(Msg.getString("K008e"));
+        }
 
         // you can't write after you read
-        if (sentRequest)
+        if (sentRequest) {
             throw new ProtocolException(Msg.getString("K0090"));
+        }
 
-        if (os != null)
+        if (os != null) {
             return os;
+        }
 
         // they are requesting a stream to write to. This implies a POST method
-        if (method == "GET")
-            setRequestMethod("POST");
+        if (method == "GET") {
+            method = "POST";
+        }
+        
         // If the request method is neither PUT or POST, then you're not writing
-        if (method != "PUT" && method != "POST")
+        if (method != "PUT" && method != "POST") {
             throw new ProtocolException(Msg.getString("K008f", method));
+        }
 
         int limit = -1;
         String contentLength = reqHeader.get("Content-Length");
-        if (contentLength != null)
+        if (contentLength != null) {
             limit = Integer.parseInt(contentLength);
+        }
 
         String encoding = reqHeader.get("Transfer-Encoding");
         if (httpVersion > 0 && encoding != null) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java?rev=407752&r1=407751&r2=407752&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java
Fri May 19 02:01:44 2006
@@ -401,6 +401,13 @@
         assertTrue(conn.getResponseCode() > 0);
     }
     
+    public void test_getOutputStream_afterConnection() throws Exception {
+        URLConnection uc = new URL("http://www.apache.org").openConnection();
+        uc.setDoOutput(true);
+        uc.connect();
+        assertNotNull(uc.getOutputStream());
+    }
+    
 	protected void setUp() {
 		try {
 			url = new URL(Support_Resources



Mime
View raw message