2004-01-23 Michael Koch <konqueror@gmx.de>

* gnu/java/net/protocol/http/Connection.java
	(connect): Don't initialize bufferedOutputStream if not needed.
	(sendRequest): Set property for content length if content is present.
	Write content only if present.
	(getOutputStream): Check if already connected, dont connect,
	initalize bufferedOutputStream if needed.

From-SVN: r76412
This commit is contained in:
Michael Koch 2004-01-23 12:32:23 +00:00 committed by Michael Koch
parent 8fac50e006
commit 5d7b2198ba
2 changed files with 22 additions and 6 deletions

View File

@ -1,3 +1,12 @@
2004-01-23 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/http/Connection.java
(connect): Don't initialize bufferedOutputStream if not needed.
(sendRequest): Set property for content length if content is present.
Write content only if present.
(getOutputStream): Check if already connected, dont connect,
initalize bufferedOutputStream if needed.
2004-01-23 Michael Koch <konqueror@gmx.de>
* java/io/FileDescriptor.java

View File

@ -168,7 +168,6 @@ public final class Connection extends HttpURLConnection
inputStream =
new DataInputStream(new BufferedInputStream(socket.getInputStream()));
outputStream = new BufferedOutputStream (socket.getOutputStream());
bufferedOutputStream = new ByteArrayOutputStream (256); //default is too small
sendRequest();
receiveReply();
@ -226,6 +225,7 @@ public final class Connection extends HttpURLConnection
setRequestProperty ("Content-type", "application/x-www-form-urlencoded");
// Set correct content length.
if (bufferedOutputStream != null)
setRequestProperty ("Content-length", String.valueOf (bufferedOutputStream.size()));
// Write all req_props name-value pairs to the output writer.
@ -242,9 +242,12 @@ public final class Connection extends HttpURLConnection
outputWriter.flush();
// Write content
if (bufferedOutputStream != null)
{
bufferedOutputStream.writeTo (outputStream);
outputStream.flush();
}
}
/**
* Read HTTP reply from inputStream.
@ -382,12 +385,16 @@ public final class Connection extends HttpURLConnection
*/
public OutputStream getOutputStream() throws IOException
{
if (connected)
throw new ProtocolException
("You cannot get an outputstream for an existing http connection");
if (!doOutput)
throw new ProtocolException
("Want output stream while haven't setDoOutput(true)");
if (!connected)
connect();
if (bufferedOutputStream == null)
bufferedOutputStream = new ByteArrayOutputStream (256); //default is too small
return bufferedOutputStream;
}