Commit a05f6447 by Michael Koch Committed by Michael Koch

HttpURLConnection.java, [...]: Reworked import statements.

2003-06-19  Michael Koch  <konqueror@gmx.de>

	* java/net/HttpURLConnection.java,
	java/net/Inet4Address.java,
	java/net/Inet6Address.java,
	java/net/SocketImpl.java,
	java/net/URLClassLoader.java:
	Reworked import statements.
	* java/net/InetAddress.java
	(getByAddress): Simplified.
	* java/net/ServerSocket.java
	(ServerSocket): Moved special handling during bind operation to
	bind().
	(bind): Handle different cases when trying to bind a socket.
	* java/net/URLConnection.java
	(getHeaderFieldDate): Merged with classpath.
	(getHeaderFieldInt): Likewise.

From-SVN: r68198
parent 3580a7d5
2003-06-19 Michael Koch <konqueror@gmx.de> 2003-06-19 Michael Koch <konqueror@gmx.de>
* java/net/HttpURLConnection.java,
java/net/Inet4Address.java,
java/net/Inet6Address.java,
java/net/SocketImpl.java,
java/net/URLClassLoader.java:
Reworked import statements.
* java/net/InetAddress.java
(getByAddress): Simplified.
* java/net/ServerSocket.java
(ServerSocket): Moved special handling during bind operation to
bind().
(bind): Handle different cases when trying to bind a socket.
* java/net/URLConnection.java
(getHeaderFieldDate): Merged with classpath.
(getHeaderFieldInt): Likewise.
2003-06-19 Michael Koch <konqueror@gmx.de>
* java/util/zip/InflaterInputStream.java * java/util/zip/InflaterInputStream.java
(InflaterInputStream): Throw NullPointerException if in is null (as (InflaterInputStream): Throw NullPointerException if in is null (as
JDK does). JDK does).
......
// HttpURLConnection.java - Subclass of communications links using /* HttpURLConnection.java - Subclass of communications links using
// Hypertext Transfer Protocol. Hypertext Transfer Protocol.
Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation
/* Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -37,9 +36,12 @@ this exception to your version of the library, but you are not ...@@ -37,9 +36,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.*; import java.io.InputStream;
import java.io.IOException;
import java.io.PushbackInputStream;
import java.security.Permission; import java.security.Permission;
/* /*
......
...@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not ...@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.IOException;
import java.io.ObjectStreamException; import java.io.ObjectStreamException;
import java.util.Arrays; import java.util.Arrays;
......
...@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not ...@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
/** /**
......
...@@ -157,57 +157,11 @@ public class ServerSocket ...@@ -157,57 +157,11 @@ public class ServerSocket
if (impl == null) if (impl == null)
throw new IOException("Cannot initialize Socket implementation"); throw new IOException("Cannot initialize Socket implementation");
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkListen(port);
if (bindAddr == null)
bindAddr = InetAddress.ANY_IF;
// create socket // create socket
impl.create(true); impl.create(true);
// bind to address/port // bind/listen socket
try bind (new InetSocketAddress (bindAddr, port), backlog);
{
impl.bind(bindAddr, port);
}
catch (IOException exception)
{
impl.close();
throw exception;
}
catch (RuntimeException exception)
{
impl.close();
throw exception;
}
catch (Error error)
{
impl.close();
throw error;
}
// listen on socket
try
{
impl.listen(backlog);
}
catch (IOException exception)
{
impl.close();
throw exception;
}
catch (RuntimeException exception)
{
impl.close();
throw exception;
}
catch (Error error)
{
impl.close();
throw error;
}
} }
/** /**
...@@ -258,9 +212,48 @@ public class ServerSocket ...@@ -258,9 +212,48 @@ public class ServerSocket
if (s != null) if (s != null)
s.checkListen (tmp.getPort ()); s.checkListen (tmp.getPort ());
// bind to address/port
try
{
impl.bind (tmp.getAddress (), tmp.getPort ()); impl.bind (tmp.getAddress (), tmp.getPort ());
}
catch (IOException exception)
{
impl.close();
throw exception;
}
catch (RuntimeException exception)
{
impl.close();
throw exception;
}
catch (Error error)
{
impl.close();
throw error;
}
// listen on socket
try
{
impl.listen(backlog); impl.listen(backlog);
} }
catch (IOException exception)
{
impl.close();
throw exception;
}
catch (RuntimeException exception)
{
impl.close();
throw exception;
}
catch (Error error)
{
impl.close();
throw error;
}
}
/** /**
* This method returns the local address to which this socket is bound * This method returns the local address to which this socket is bound
......
/* SocketImpl.java -- Abstract socket implementation class /* SocketImpl.java -- Abstract socket implementation class
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -35,9 +36,13 @@ this exception to your version of the library, but you are not ...@@ -35,9 +36,13 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.*; import java.io.FileDescriptor;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
/* Written using on-line Java Platform 1.2 API Specification. /* Written using on-line Java Platform 1.2 API Specification.
* Believed complete and correct. * Believed complete and correct.
......
...@@ -35,14 +35,13 @@ this exception to your version of the library, but you are not ...@@ -35,14 +35,13 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.EOFException; import java.io.EOFException;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilterInputStream;
import java.io.FilePermission; import java.io.FilePermission;
import java.io.InputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
...@@ -60,7 +59,6 @@ import java.util.jar.Attributes; ...@@ -60,7 +59,6 @@ import java.util.jar.Attributes;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import java.util.zip.ZipException;
/** /**
* A secure class loader that can load classes and resources from * A secure class loader that can load classes and resources from
......
...@@ -331,20 +331,19 @@ public abstract class URLConnection ...@@ -331,20 +331,19 @@ public abstract class URLConnection
*/ */
public int getHeaderFieldInt(String name, int defaultValue) public int getHeaderFieldInt(String name, int defaultValue)
{ {
String str = getHeaderField(name); String value = getHeaderField (name);
int result = defaultValue;
if (value == null)
return defaultValue;
try try
{ {
if (str != null) return Integer.parseInt (value);
result = Integer.parseInt (str);
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
; // Do nothing; defaultValue is the default. return defaultValue;
} }
return result;
} }
/** /**
...@@ -353,27 +352,32 @@ public abstract class URLConnection ...@@ -353,27 +352,32 @@ public abstract class URLConnection
* value if the field is not present or cannot be converted to a date. * value if the field is not present or cannot be converted to a date.
* *
* @param name The name of the header field * @param name The name of the header field
* @param val The dafault date * @param defaultValue The default date if the header field is not found
* or can't be converted.
* *
* @return Returns the date value of the header filed or the default value * @return Returns the date value of the header filed or the default value
* if the field is missing or malformed * if the field is missing or malformed
*/ */
public long getHeaderFieldDate(String name, long val) public long getHeaderFieldDate (String name, long defaultValue)
{ {
if (! dateformats_initialized) if (! dateformats_initialized)
initializeDateFormats(); initializeDateFormats ();
String str = getHeaderField(name);
long result = defaultValue;
String str = getHeaderField (name);
if (str != null) if (str != null)
{ {
Date date; Date date;
if ((date = dateFormat1.parse(str, new ParsePosition(0))) != null) if ((date = dateFormat1.parse (str, new ParsePosition (0))) != null)
val = date.getTime(); result = date.getTime ();
else if ((date = dateFormat2.parse(str, new ParsePosition(0))) != null) else if ((date = dateFormat2.parse (str, new ParsePosition (0))) != null)
val = date.getTime(); result = date.getTime ();
else if ((date = dateFormat3.parse(str, new ParsePosition(0))) != null) else if ((date = dateFormat3.parse (str, new ParsePosition (0))) != null)
val = date.getTime(); result = date.getTime ();
} }
return val;
return result;
} }
/** /**
...@@ -387,7 +391,7 @@ public abstract class URLConnection ...@@ -387,7 +391,7 @@ public abstract class URLConnection
* @return The header field key or null if index is past the end * @return The header field key or null if index is past the end
* of the headers. * of the headers.
*/ */
public String getHeaderFieldKey(int index) public String getHeaderFieldKey (int index)
{ {
// Subclasses for specific protocols override this. // Subclasses for specific protocols override this.
return null; return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment