This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: gnu.java.net.protocol.http.Connection
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 2 Dec 2003 15:51:48 +0100
- Subject: FYI: Patch: gnu.java.net.protocol.http.Connection
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I commited the attached patch to get
gnu.java.net.protocol.http.Connection more in line with classpath.
This patch removes support for default request properties as it was
done in JDK 1.3.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/zKcEWSOgCCdjSDsRAqTyAJ40Hy70QUK0YxB/XqnsBMOX8SX2GwCghAXU
MnPTj5UEfC+LZdfWPkLX570=
=yhpo
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2395
diff -u -b -B -r1.2395 ChangeLog
--- ChangeLog 2 Dec 2003 13:13:22 -0000 1.2395
+++ ChangeLog 2 Dec 2003 13:43:43 -0000
@@ -1,5 +1,17 @@
2003-12-02 Michael Koch <konqueror@gmx.de>
+ * gnu/java/net/protocol//http/Connection.java
+ (defRequestProperties): Removed. This dont gets used since JDK 1.3.
+ (requestProperties): Initialize, documentation added.
+ (inputStream): Renamed from bufferedIn.
+ (Connection): Dont initialize requestProperties.
+ (setDefaultRequestProperty): Removed.
+ (getDefaultRequestProperty): Removed.
+ (usingProxy): Documentation added.
+ (getHttpHeaders): Likewise.
+
+2003-12-02 Michael Koch <konqueror@gmx.de>
+
* java/text/DateFormat.java:
Explicitely import used classes.
Index: gnu/java/net/protocol//http/Connection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/protocol/http/Connection.java,v
retrieving revision 1.4
diff -u -b -B -r1.4 Connection.java
--- gnu/java/net/protocol//http/Connection.java 1 Dec 2003 16:35:45 -0000 1.4
+++ gnu/java/net/protocol//http/Connection.java 2 Dec 2003 13:43:43 -0000
@@ -72,12 +72,6 @@
* The socket we are connected to
*/
private Socket socket;
- private static Hashtable defRequestProperties = new Hashtable();
- private Hashtable requestProperties;
- private Hashtable hdrHash = new Hashtable();
- private Vector hdrVec = new Vector();
- private BufferedInputStream bufferedIn;
-
private static int proxyPort = 80;
private static boolean proxyInUse = false;
private static String proxyHost = null;
@@ -106,27 +100,25 @@
}
/**
+ * The InputStream for this connection.
+ */
+ private BufferedInputStream inputStream;
+
+ /**
+ * This is the object that holds the header field information
+ */
+ private Hashtable requestProperties = new Hashtable();
+ private Hashtable hdrHash = new Hashtable();
+ private Vector hdrVec = new Vector();
+
+ /**
* Calls superclass constructor to initialize
*/
protected Connection(URL url)
{
super(url);
- requestProperties = (Hashtable) defRequestProperties.clone();
}
- // Override method in URLConnection.
- public static void setDefaultRequestProperty(String key, String value)
- {
- defRequestProperties.put(key, value);
- }
-
- // Override method in URLConnection.
- public static String getDefaultRequestProperty(String key)
- {
- return (String) defRequestProperties.get(key);
- }
-
- // Override method in URLConnection.
public void setRequestProperty(String key, String value)
{
if (connected)
@@ -135,7 +127,6 @@
requestProperties.put(key, value);
}
- // Override method in URLConnection.
public String getRequestProperty(String key)
{
if (connected)
@@ -195,7 +186,7 @@
{
socket.close();
}
- catch (IOException ex)
+ catch (IOException e)
{
// Ignore errors in closing socket.
}
@@ -203,12 +194,17 @@
}
}
+ /**
+ * Return a boolean indicating whether or not this connection is
+ * going through a proxy
+ *
+ * @return true if using a proxy, false otherwise
+ */
public boolean usingProxy()
{
return proxyInUse;
}
- // Override default method in URLConnection.
public InputStream getInputStream() throws IOException
{
if (!connected)
@@ -216,10 +212,10 @@
if (!doInput)
throw new ProtocolException("Can't open InputStream if doInput is false");
- return bufferedIn;
+
+ return inputStream;
}
- // Override default method in URLConnection.
public OutputStream getOutputStream() throws IOException
{
if (!connected)
@@ -231,7 +227,6 @@
return socket.getOutputStream();
}
- // Override default method in URLConnection.
public String getHeaderField(String name)
{
if (!connected)
@@ -247,7 +242,6 @@
return (String) hdrHash.get(name.toLowerCase());
}
- // Override default method in URLConnection.
public Map getHeaderFields()
{
if (!connected)
@@ -263,7 +257,6 @@
return hdrHash;
}
- // Override default method in URLConnection.
public String getHeaderField(int n)
{
if (!connected)
@@ -281,7 +274,6 @@
return null;
}
- // Override default method in URLConnection.
public String getHeaderFieldKey(int n)
{
if (!connected)
@@ -321,6 +313,9 @@
return str;
}
+ /**
+ * Read HTTP reply from inputStream.
+ */
private void getHttpHeaders() throws IOException
{
// Originally tried using a BufferedReader here to take advantage of
@@ -329,7 +324,7 @@
// It is probably more robust than it needs to be, e.g. the byte[]
// is unlikely to overflow and a '\r' should always be followed by a '\n',
// but it is better to be safe just in case.
- bufferedIn = new BufferedInputStream(socket.getInputStream());
+ inputStream = new BufferedInputStream(socket.getInputStream());
int buflen = 100;
byte[] buf = new byte[buflen];
@@ -348,12 +343,12 @@
// FIXME: This is rather inefficient.
for (i = 0; i < buflen; i++)
{
- buf[i] = (byte) bufferedIn.read();
+ buf[i] = (byte) inputStream.read();
if (buf[i] == -1)
throw new IOException("Malformed HTTP header");
if (buf[i] == '\r')
{
- bufferedIn.read(ch, 0, 1);
+ inputStream.read(ch, 0, 1);
if (ch[0] == '\n')
gotnl = true;
break;