summaryrefslogtreecommitdiffstats
path: root/libjava
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-12-27 17:24:51 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-12-27 17:24:51 +0000
commit5127eb8c2c819702225b08de06319a3ee0148be7 (patch)
tree229ae20fc934b92566fd1b035f78d736cb4d53d4 /libjava
parentf6df144a51f6df4ab5f69c781f796e6a912ade6a (diff)
downloadppe42-gcc-5127eb8c2c819702225b08de06319a3ee0148be7.tar.gz
ppe42-gcc-5127eb8c2c819702225b08de06319a3ee0148be7.zip
2003-12-27 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/http/Connection.java (connect): Call receiveReply(). (receiveReply): Renamed from getHttpHeaders(). (getOutputStream): Moved check on doOutput before check for connection state. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75172 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog8
-rw-r--r--libjava/gnu/java/net/protocol/http/Connection.java129
2 files changed, 77 insertions, 60 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 434c66bde9c..3714570ccad 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,13 @@
2003-12-27 Michael Koch <konqueror@gmx.de>
+ * gnu/java/net/protocol/http/Connection.java
+ (connect): Call receiveReply().
+ (receiveReply): Renamed from getHttpHeaders().
+ (getOutputStream): Moved check on doOutput before check for connection
+ state.
+
+2003-12-27 Michael Koch <konqueror@gmx.de>
+
* javax/print/attribute/ResolutionSyntax.java,
javax/print/attribute/SetOfIntegerSyntax.java,
javax/print/attribute/Size2DSyntax.java,
diff --git a/libjava/gnu/java/net/protocol/http/Connection.java b/libjava/gnu/java/net/protocol/http/Connection.java
index b564afb376f..632a20a81bc 100644
--- a/libjava/gnu/java/net/protocol/http/Connection.java
+++ b/libjava/gnu/java/net/protocol/http/Connection.java
@@ -172,7 +172,8 @@ public final class Connection extends HttpURLConnection
inputStream = new BufferedInputStream(socket.getInputStream());
sendRequest();
- getHttpHeaders();
+ receiveReply();
+
connected = true;
}
@@ -226,6 +227,62 @@ public final class Connection extends HttpURLConnection
}
/**
+ * Read HTTP reply from inputStream.
+ */
+ private void receiveReply() throws IOException
+ {
+ int buflen = 100;
+ byte[] buf = new byte[buflen];
+ String line = "";
+ boolean gotnl = false;
+ byte[] ch = new byte[1];
+ ch[0] = (byte) '\n';
+
+ while (true)
+ {
+ // Check for leftover byte from non-'\n' after a '\r'.
+ if (ch[0] != '\n')
+ line = line + '\r' + new String(ch, 0, 1);
+
+ int i;
+ // FIXME: This is rather inefficient.
+ for (i = 0; i < buflen; i++)
+ {
+ buf[i] = (byte) inputStream.read();
+ if (buf[i] == -1)
+ throw new IOException("Malformed HTTP header");
+ if (buf[i] == '\r')
+ {
+ inputStream.read(ch, 0, 1);
+ if (ch[0] == '\n')
+ gotnl = true;
+ break;
+ }
+ }
+ line = line + new String(buf, 0, i);
+
+ // A '\r' '\n' combo indicates the end of the header entry.
+ // If it wasn't found, cycle back through the loop and append
+ // to 'line' until one is found.
+ if (gotnl)
+ {
+ // A zero length entry signals the end of the headers.
+ if (line.length() == 0)
+ break;
+
+ // Store the header and reinitialize for next cycle.
+ hdrVec.addElement(line);
+ String key = getKey(line);
+ if (key != null)
+ hdrHash.put(key.toLowerCase(), getField(line));
+ line = "";
+ ch[0] = (byte) '\n';
+ gotnl = false;
+ }
+ }
+ }
+
+ /**
* Return a boolean indicating whether or not this connection is
* going through a proxy
*
@@ -256,13 +313,21 @@ public final class Connection extends HttpURLConnection
return inputStream;
}
+ /**
+ * Returns on OutputStream for writing to this connection.
+ *
+ * @return An OutputStream for this connection.
+ *
+ * @exception IOException If an error occurs
+ */
public OutputStream getOutputStream() throws IOException
{
+ if (!doOutput)
+ throw new ProtocolException
+ ("Want output stream while haven't setDoOutput(true)");
+
if (!connected)
connect();
-
- if (! doOutput)
- throw new ProtocolException("Can't open OutputStream if doOutput is false");
return socket.getOutputStream();
}
@@ -389,60 +454,4 @@ public final class Connection extends HttpURLConnection
else
return str;
}
-
- /**
- * Read HTTP reply from inputStream.
- */
- private void getHttpHeaders() throws IOException
- {
- int buflen = 100;
- byte[] buf = new byte[buflen];
- String line = "";
- boolean gotnl = false;
- byte[] ch = new byte[1];
- ch[0] = (byte) '\n';
-
- while (true)
- {
- // Check for leftover byte from non-'\n' after a '\r'.
- if (ch[0] != '\n')
- line = line + '\r' + new String(ch, 0, 1);
-
- int i;
- // FIXME: This is rather inefficient.
- for (i = 0; i < buflen; i++)
- {
- buf[i] = (byte) inputStream.read();
- if (buf[i] == -1)
- throw new IOException("Malformed HTTP header");
- if (buf[i] == '\r')
- {
- inputStream.read(ch, 0, 1);
- if (ch[0] == '\n')
- gotnl = true;
- break;
- }
- }
- line = line + new String(buf, 0, i);
-
- // A '\r' '\n' combo indicates the end of the header entry.
- // If it wasn't found, cycle back through the loop and append
- // to 'line' until one is found.
- if (gotnl)
- {
- // A zero length entry signals the end of the headers.
- if (line.length() == 0)
- break;
-
- // Store the header and reinitialize for next cycle.
- hdrVec.addElement(line);
- String key = getKey(line);
- if (key != null)
- hdrHash.put(key.toLowerCase(), getField(line));
- line = "";
- ch[0] = (byte) '\n';
- gotnl = false;
- }
- }
- }
}
OpenPOWER on IntegriCloud