aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-12-04 17:52:01 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-12-04 17:52:01 +0000
commit89231ff02754a9b1e61574be44be24a5b5c1f1a4 (patch)
tree60f4ac855ef30dc3d82bdb1eefe80c85a51d8ee6 /libjava
parent0ee646d6ac66a54d4dd9a015a513ac365542e796 (diff)
downloadgcc-89231ff02754a9b1e61574be44be24a5b5c1f1a4.zip
gcc-89231ff02754a9b1e61574be44be24a5b5c1f1a4.tar.gz
gcc-89231ff02754a9b1e61574be44be24a5b5c1f1a4.tar.bz2
2003-12-04 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/http/Connection.java (sendRequest): Merged writing http headers with classpath. (getInputStream): Merged documentation from classpath. (getHeaderField): Likewise. (getHeaderFieldKey): Likewise. From-SVN: r74283
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog8
-rw-r--r--libjava/gnu/java/net/protocol/http/Connection.java62
2 files changed, 63 insertions, 7 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index a342422..99b9250 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,13 @@
2003-12-04 Michael Koch <konqueror@gmx.de>
+ * gnu/java/net/protocol/http/Connection.java
+ (sendRequest): Merged writing http headers with classpath.
+ (getInputStream): Merged documentation from classpath.
+ (getHeaderField): Likewise.
+ (getHeaderFieldKey): Likewise.
+
+2003-12-04 Michael Koch <konqueror@gmx.de>
+
* boehm.cc (_Jv_MarkObj): Access hack_signers field.
2003-12-04 Michael Koch <konqueror@gmx.de>
diff --git a/libjava/gnu/java/net/protocol/http/Connection.java b/libjava/gnu/java/net/protocol/http/Connection.java
index ae13dff..b564afb 100644
--- a/libjava/gnu/java/net/protocol/http/Connection.java
+++ b/libjava/gnu/java/net/protocol/http/Connection.java
@@ -48,10 +48,10 @@ import java.net.ProtocolException;
import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
+import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import java.util.Hashtable;
-import java.util.Enumeration;
/**
* This subclass of java.net.URLConnection models a URLConnection via
@@ -212,12 +212,14 @@ public final class Connection extends HttpURLConnection
setRequestProperty ("Host", url.getHost());
// Write all req_props name-value pairs to the output writer.
- Enumeration reqKeys = requestProperties.keys();
- Enumeration reqVals = requestProperties.elements();
-
- while (reqKeys.hasMoreElements())
- outputWriter.print (reqKeys.nextElement() + ": " + reqVals.nextElement() + "\r\n");
-
+ Iterator itr = getRequestProperties().entrySet().iterator();
+
+ while (itr.hasNext())
+ {
+ Map.Entry e = (Map.Entry) itr.next();
+ outputWriter.print (e.getKey() + ": " + e.getValue() + "\r\n");
+ }
+
// One more CR-LF indicates end of header.
outputWriter.print ("\r\n");
outputWriter.flush();
@@ -234,6 +236,15 @@ public final class Connection extends HttpURLConnection
return proxyInUse;
}
+ /**
+ * Returns an InputStream for reading from this connection. This stream
+ * will be "queued up" for reading just the contents of the requested file.
+ * Overrides URLConnection.getInputStream()
+ *
+ * @return An InputStream for this connection.
+ *
+ * @exception IOException If an error occurs
+ */
public InputStream getInputStream() throws IOException
{
if (!connected)
@@ -256,6 +267,25 @@ public final class Connection extends HttpURLConnection
return socket.getOutputStream();
}
+ /**
+ * Overrides java.net.HttpURLConnection.setRequestMethod() in order to
+ * restrict the available methods to only those we support.
+ *
+ * @param method The RequestMethod to use
+ *
+ * @exception ProtocolException If the specified method is not valid
+ */
+ public void setRequestMethod (String method) throws ProtocolException
+ {
+ method = method.toUpperCase();
+
+ if (method.equals("GET"))
+ super.setRequestMethod (method);
+ else
+ throw new ProtocolException ("Unsupported or unknown request method " +
+ method);
+ }
+
public String getHeaderField(String name)
{
if (!connected)
@@ -286,6 +316,15 @@ public final class Connection extends HttpURLConnection
return hdrHash;
}
+ /**
+ * This method returns the header field value at the specified numeric
+ * index.
+ *
+ * @param n The index into the header field array
+ *
+ * @return The value of the specified header field, or <code>null</code>
+ * if the specified index is not valid.
+ */
public String getHeaderField(int n)
{
if (!connected)
@@ -303,6 +342,15 @@ public final class Connection extends HttpURLConnection
return null;
}
+ /**
+ * This method returns the header field key at the specified numeric
+ * index.
+ *
+ * @param n The index into the header field array
+ *
+ * @return The name of the header field key, or <code>null</code> if the
+ * specified index is not valid.
+ */
public String getHeaderFieldKey(int n)
{
if (!connected)