summaryrefslogtreecommitdiffstats
path: root/libjava/java/net/HttpURLConnection.java
diff options
context:
space:
mode:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2000-08-10 09:10:25 +0000
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2000-08-10 09:10:25 +0000
commit43060331a4f27819d8ff9f4eeca1a15486d6793f (patch)
treec83f347809df3815635d9eb31211347f39ca2f5a /libjava/java/net/HttpURLConnection.java
parent24f5c60b03c4b79ca7d6cf68657066c2566e8c04 (diff)
downloadppe42-gcc-43060331a4f27819d8ff9f4eeca1a15486d6793f.tar.gz
ppe42-gcc-43060331a4f27819d8ff9f4eeca1a15486d6793f.zip
2000-08-10 Bryce McKinlay <bryce@albatross.co.nz>
John Stracke <francis@ecal.com> * gnu/gcj/protocol/http/Connection.java (gotHeaders): Removed. (connect): Don't falsely claim HTTP/1.1 compliance. Call getHttpHeaders(). (disconnect): Don't unset connected flag. (getHeaderField (String)): Call connect() if not connected. (getHeaderField (int)): Ditto. (getHeaderFieldKey): Ditto. (getHttpHeaders): Don't call connect(). * java/net/HttpURLConnection.java (instanceFollowRedirects, gotResponseVals): New fields. (getResponseCode): Call getResponseVals() conditionally. (getResponseMessage): Ditto. (getResponseVals): Call connect(). Don't throw FileNotFoundException. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35603 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/net/HttpURLConnection.java')
-rw-r--r--libjava/java/net/HttpURLConnection.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/libjava/java/net/HttpURLConnection.java b/libjava/java/net/HttpURLConnection.java
index 673cc8aa2b0..84e9468dfc2 100644
--- a/libjava/java/net/HttpURLConnection.java
+++ b/libjava/java/net/HttpURLConnection.java
@@ -1,7 +1,7 @@
// HttpURLConnection.java - Subclass of communications links using
// Hypertext Transfer Protocol.
-/* Copyright (C) 1999 Free Software Foundation
+/* Copyright (C) 1999, 2000 Free Software Foundation
This file is part of libgcj.
@@ -69,11 +69,14 @@ public abstract class HttpURLConnection extends URLConnection
public static final int HTTP_GATEWAY_TIMEOUT = 504;
public static final int HTTP_VERSION = 505;
+ static boolean followRedirects = true;
+
protected String method = "GET";
protected int responseCode = -1;
protected String responseMessage;
+ protected boolean instanceFollowRedirects = followRedirects;
- static boolean followRedirects = true;
+ private boolean gotResponseVals = false;
protected HttpURLConnection(URL url)
{
@@ -121,21 +124,30 @@ public abstract class HttpURLConnection extends URLConnection
public int getResponseCode() throws IOException
{
- getResponseVals();
+ if (!gotResponseVals)
+ getResponseVals();
return responseCode;
}
public String getResponseMessage() throws IOException
{
- getResponseVals();
+ if (!gotResponseVals)
+ getResponseVals();
return responseMessage;
}
private void getResponseVals() throws IOException
{
+ // getHeaderField() will connect for us, but do it here first in
+ // order to pick up IOExceptions.
+ if (!connected)
+ connect();
+
+ gotResponseVals = true;
// Response is the first header received from the connection.
String respField = getHeaderField(0);
- if (! respField.startsWith("HTTP/"))
+
+ if (respField == null || ! respField.startsWith("HTTP/"))
{
// Set to default values on failure.
responseCode = -1;
@@ -158,10 +170,6 @@ public abstract class HttpURLConnection extends URLConnection
responseCode = -1;
responseMessage = null;
}
- if (responseCode == HTTP_NOT_FOUND)
- throw new FileNotFoundException(url.toString());
- else if (responseCode >= 400)
- throw new IOException(url.toString() + " " + respField);
}
// TODO12: public Permission getPermission() throws IOException
OpenPOWER on IntegriCloud