[kaffe] [PATCH] HttpURLConnection.getOutputStream() fix
Atsushi Nemoto
anemo at mba.ocn.ne.jp
Thu Dec 11 05:24:01 PST 2003
I tried to send POST request to HttpURLConnection but writing to
streams returned by HttpURLConnection.getOutputStream() had no effect.
This is because getOutputStream() calls connect() before any data is
written to the stream.
Here is a patch to fix it.
diff -ur kaffe-1.1.3/libraries/javalib/gnu/java/net/protocol/http/Connection.java kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java
--- kaffe-1.1.3/libraries/javalib/gnu/java/net/protocol/http/Connection.java Thu Dec 4 05:33:39 2003
+++ kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java Wed Dec 10 18:51:51 2003
@@ -169,7 +169,8 @@
(new BufferedInputStream (socket.getInputStream()));
outputStream = new BufferedOutputStream (socket.getOutputStream());
- bufferedOutputStream = new ByteArrayOutputStream (256); //default is too small
+ if (bufferedOutputStream == null)
+ bufferedOutputStream = new ByteArrayOutputStream ();
outputWriter = new PrintWriter (new OutputStreamWriter (outputStream, "8859_1"));
sendRequest();
@@ -437,9 +438,8 @@
if (!method.equals ("POST")) //But we might support "PUT" in future
setRequestMethod ("POST");
- if (!connected)
- connect();
-
+ if(bufferedOutputStream == null)
+ bufferedOutputStream = new ByteArrayOutputStream (256); //default is too small
return bufferedOutputStream;
}
---
Atsushi Nemoto
More information about the kaffe
mailing list