mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-09 22:20:13 +08:00
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
This commit is contained in:
parent
3580a7d585
commit
a05f6447e3
@ -1,3 +1,21 @@
|
|||||||
|
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>
|
2003-06-19 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
* java/util/zip/InflaterInputStream.java
|
* java/util/zip/InflaterInputStream.java
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// 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
|
|||||||
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
|
|||||||
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
|
|||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,15 +92,15 @@ public class InetAddress implements Serializable
|
|||||||
// FIXME: implement this
|
// FIXME: implement this
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(ObjectInputStream ois)
|
private void readObject (ObjectInputStream ois)
|
||||||
throws IOException, ClassNotFoundException
|
throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
ois.defaultReadObject();
|
ois.defaultReadObject ();
|
||||||
addr = new byte[4];
|
addr = new byte [4];
|
||||||
addr[3] = (byte) address;
|
addr [3] = (byte) address;
|
||||||
|
|
||||||
for (int i = 2; i >= 0; --i)
|
for (int i = 2; i >= 0; --i)
|
||||||
addr[i] = (byte) (address >>= 8);
|
addr [i] = (byte) (address >>= 8);
|
||||||
|
|
||||||
// Ignore family from serialized data. Since the saved address is 32 bits
|
// Ignore family from serialized data. Since the saved address is 32 bits
|
||||||
// the deserialized object will have an IPv4 address i.e. AF_INET family.
|
// the deserialized object will have an IPv4 address i.e. AF_INET family.
|
||||||
@ -110,7 +110,7 @@ public class InetAddress implements Serializable
|
|||||||
family = getFamily (addr);
|
family = getFamily (addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeObject(ObjectOutputStream oos) throws IOException
|
private void writeObject (ObjectOutputStream oos) throws IOException
|
||||||
{
|
{
|
||||||
// Build a 32 bit address from the last 4 bytes of a 4 byte IPv4 address
|
// Build a 32 bit address from the last 4 bytes of a 4 byte IPv4 address
|
||||||
// or a 16 byte IPv6 address.
|
// or a 16 byte IPv6 address.
|
||||||
@ -118,9 +118,9 @@ public class InetAddress implements Serializable
|
|||||||
int i = len - 4;
|
int i = len - 4;
|
||||||
|
|
||||||
for (; i < len; i++)
|
for (; i < len; i++)
|
||||||
address = address << 8 | (((int) addr[i]) & 0xFF);
|
address = address << 8 | (((int) addr [i]) & 0xFF);
|
||||||
|
|
||||||
oos.defaultWriteObject();
|
oos.defaultWriteObject ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native int getFamily (byte[] address);
|
private static native int getFamily (byte[] address);
|
||||||
@ -144,10 +144,10 @@ public class InetAddress implements Serializable
|
|||||||
int len = addr.length;
|
int len = addr.length;
|
||||||
|
|
||||||
if (len == 4)
|
if (len == 4)
|
||||||
return (addr[0] & 0xF0) == 0xE0;
|
return (addr [0] & 0xF0) == 0xE0;
|
||||||
|
|
||||||
if (len == 16)
|
if (len == 16)
|
||||||
return addr[0] == (byte) 0xFF;
|
return addr [0] == (byte) 0xFF;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ public class InetAddress implements Serializable
|
|||||||
// This is the IPv4 implementation.
|
// This is the IPv4 implementation.
|
||||||
// Any class derived from InetAddress should override this.
|
// Any class derived from InetAddress should override this.
|
||||||
|
|
||||||
return addr[0] == 0x7F;
|
return addr [0] == 0x7F;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,7 +202,7 @@ public class InetAddress implements Serializable
|
|||||||
// Any class derived from InetAddress should override this.
|
// Any class derived from InetAddress should override this.
|
||||||
|
|
||||||
// 10.0.0.0/8
|
// 10.0.0.0/8
|
||||||
if (addr[0] == 0x0A)
|
if (addr [0] == 0x0A)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here:
|
// XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here:
|
||||||
@ -263,9 +263,9 @@ public class InetAddress implements Serializable
|
|||||||
if (!isMulticastAddress ())
|
if (!isMulticastAddress ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (addr[0] == 0xE0
|
return (addr [0] == 0xE0
|
||||||
&& addr[1] == 0x00
|
&& addr [1] == 0x00
|
||||||
&& addr[2] == 0x00);
|
&& addr [2] == 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -340,26 +340,26 @@ public class InetAddress implements Serializable
|
|||||||
{
|
{
|
||||||
// An experiment shows that JDK1.2 returns a different byte array each
|
// An experiment shows that JDK1.2 returns a different byte array each
|
||||||
// time. This makes sense, in terms of security.
|
// time. This makes sense, in terms of security.
|
||||||
return (byte[]) addr.clone();
|
return (byte[]) addr.clone ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper function due to a CNI limitation. */
|
/* Helper function due to a CNI limitation. */
|
||||||
private static InetAddress[] allocArray (int count)
|
private static InetAddress[] allocArray (int count)
|
||||||
{
|
{
|
||||||
return new InetAddress[count];
|
return new InetAddress [count];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper function due to a CNI limitation. */
|
/* Helper function due to a CNI limitation. */
|
||||||
private static SecurityException checkConnect (String hostname)
|
private static SecurityException checkConnect (String hostname)
|
||||||
{
|
{
|
||||||
SecurityManager s = System.getSecurityManager();
|
SecurityManager s = System.getSecurityManager ();
|
||||||
|
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
s.checkConnect(hostname, -1);
|
s.checkConnect (hostname, -1);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (SecurityException ex)
|
catch (SecurityException ex)
|
||||||
@ -375,7 +375,7 @@ public class InetAddress implements Serializable
|
|||||||
*/
|
*/
|
||||||
public String getHostAddress ()
|
public String getHostAddress ()
|
||||||
{
|
{
|
||||||
StringBuffer sbuf = new StringBuffer(40);
|
StringBuffer sbuf = new StringBuffer (40);
|
||||||
int len = addr.length;
|
int len = addr.length;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (len == 16)
|
if (len == 16)
|
||||||
@ -383,37 +383,37 @@ public class InetAddress implements Serializable
|
|||||||
for (; ; i += 2)
|
for (; ; i += 2)
|
||||||
{
|
{
|
||||||
if (i >= 16)
|
if (i >= 16)
|
||||||
return sbuf.toString();
|
return sbuf.toString ();
|
||||||
int x = ((addr[i] & 0xFF) << 8) | (addr[i+1] & 0xFF);
|
int x = ((addr [i] & 0xFF) << 8) | (addr [i + 1] & 0xFF);
|
||||||
boolean empty = sbuf.length() == 0;
|
boolean empty = sbuf.length () == 0;
|
||||||
if (empty)
|
if (empty)
|
||||||
{
|
{
|
||||||
if (i == 10 && x == 0xFFFF)
|
if (i == 10 && x == 0xFFFF)
|
||||||
{ // IPv4-mapped IPv6 address.
|
{ // IPv4-mapped IPv6 address.
|
||||||
sbuf.append(":FFFF:");
|
sbuf.append (":FFFF:");
|
||||||
break; // Continue as IPv4 address;
|
break; // Continue as IPv4 address;
|
||||||
}
|
}
|
||||||
else if (i == 12)
|
else if (i == 12)
|
||||||
{ // IPv4-compatible IPv6 address.
|
{ // IPv4-compatible IPv6 address.
|
||||||
sbuf.append(':');
|
sbuf.append (':');
|
||||||
break; // Continue as IPv4 address.
|
break; // Continue as IPv4 address.
|
||||||
}
|
}
|
||||||
else if (i > 0)
|
else if (i > 0)
|
||||||
sbuf.append("::");
|
sbuf.append ("::");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sbuf.append(':');
|
sbuf.append (':');
|
||||||
if (x != 0 || i >= 14)
|
if (x != 0 || i >= 14)
|
||||||
sbuf.append(Integer.toHexString(x).toUpperCase());
|
sbuf.append (Integer.toHexString (x).toUpperCase ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ( ; ; )
|
for ( ; ; )
|
||||||
{
|
{
|
||||||
sbuf.append(addr[i] & 0xFF);
|
sbuf.append (addr[i] & 0xFF);
|
||||||
i++;
|
i++;
|
||||||
if (i == len)
|
if (i == len)
|
||||||
break;
|
break;
|
||||||
sbuf.append('.');
|
sbuf.append ('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return sbuf.toString();
|
return sbuf.toString();
|
||||||
@ -422,7 +422,7 @@ public class InetAddress implements Serializable
|
|||||||
/**
|
/**
|
||||||
* Returns a hashcode of the InetAddress
|
* Returns a hashcode of the InetAddress
|
||||||
*/
|
*/
|
||||||
public int hashCode()
|
public int hashCode ()
|
||||||
{
|
{
|
||||||
// There hashing algorithm is not specified, but a simple experiment
|
// There hashing algorithm is not specified, but a simple experiment
|
||||||
// shows that it is equal to the address, as a 32-bit big-endian integer.
|
// shows that it is equal to the address, as a 32-bit big-endian integer.
|
||||||
@ -467,10 +467,10 @@ public class InetAddress implements Serializable
|
|||||||
/**
|
/**
|
||||||
* Returns then <code>InetAddress</code> as string
|
* Returns then <code>InetAddress</code> as string
|
||||||
*/
|
*/
|
||||||
public String toString()
|
public String toString ()
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
String address = getHostAddress();
|
String address = getHostAddress ();
|
||||||
|
|
||||||
if (hostName != null)
|
if (hostName != null)
|
||||||
result = hostName + "/" + address;
|
result = hostName + "/" + address;
|
||||||
@ -492,16 +492,10 @@ public class InetAddress implements Serializable
|
|||||||
*
|
*
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public static InetAddress getByAddress(byte[] addr)
|
public static InetAddress getByAddress (byte[] addr)
|
||||||
throws UnknownHostException
|
throws UnknownHostException
|
||||||
{
|
{
|
||||||
if (addr.length != 4 && addr.length != 16)
|
return getByAddress (null, addr);
|
||||||
throw new UnknownHostException ("IP address has illegal length");
|
|
||||||
|
|
||||||
if (addr.length == 4)
|
|
||||||
return new Inet4Address (addr, null);
|
|
||||||
|
|
||||||
return new Inet6Address (addr, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -553,7 +547,7 @@ public class InetAddress implements Serializable
|
|||||||
|
|
||||||
// Default to current host if necessary
|
// Default to current host if necessary
|
||||||
if (hostname == null)
|
if (hostname == null)
|
||||||
return getLocalHost();
|
return getLocalHost ();
|
||||||
|
|
||||||
// Assume that the host string is an IP address
|
// Assume that the host string is an IP address
|
||||||
byte[] address = aton (hostname);
|
byte[] address = aton (hostname);
|
||||||
@ -563,13 +557,13 @@ public class InetAddress implements Serializable
|
|||||||
return new Inet4Address (address, null);
|
return new Inet4Address (address, null);
|
||||||
else if (address.length == 16)
|
else if (address.length == 16)
|
||||||
{
|
{
|
||||||
if ((address[10] == 0xFF) && (address[11] == 0xFF))
|
if ((address [10] == 0xFF) && (address [11] == 0xFF))
|
||||||
{
|
{
|
||||||
byte[] ip4addr = new byte[4];
|
byte[] ip4addr = new byte [4];
|
||||||
ip4addr[0] = address[12];
|
ip4addr [0] = address [12];
|
||||||
ip4addr[1] = address[13];
|
ip4addr [1] = address [13];
|
||||||
ip4addr[2] = address[14];
|
ip4addr [2] = address [14];
|
||||||
ip4addr[3] = address[15];
|
ip4addr [3] = address [15];
|
||||||
return new Inet4Address (ip4addr, null);
|
return new Inet4Address (ip4addr, null);
|
||||||
}
|
}
|
||||||
return new Inet6Address (address, null);
|
return new Inet6Address (address, null);
|
||||||
@ -580,7 +574,7 @@ public class InetAddress implements Serializable
|
|||||||
|
|
||||||
// Try to resolve the host by DNS
|
// Try to resolve the host by DNS
|
||||||
InetAddress[] addresses = getAllByName (hostname);
|
InetAddress[] addresses = getAllByName (hostname);
|
||||||
return addresses[0];
|
return addresses [0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -603,8 +597,8 @@ public class InetAddress implements Serializable
|
|||||||
byte[] address = aton (hostname);
|
byte[] address = aton (hostname);
|
||||||
if (address != null)
|
if (address != null)
|
||||||
{
|
{
|
||||||
InetAddress[] result = new InetAddress[1];
|
InetAddress[] result = new InetAddress [1];
|
||||||
result[0] = new InetAddress(address, null);
|
result [0] = new InetAddress (address, null);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,10 +606,10 @@ public class InetAddress implements Serializable
|
|||||||
return lookup (hostname, null, true);
|
return lookup (hostname, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final byte[] zeros = {0,0,0,0};
|
static final byte[] zeros = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
/* dummy InetAddress, used to bind socket to any (all) network interfaces */
|
/* dummy InetAddress, used to bind socket to any (all) network interfaces */
|
||||||
static final InetAddress ANY_IF = new InetAddress(zeros, null);
|
static final InetAddress ANY_IF = new InetAddress (zeros, null);
|
||||||
|
|
||||||
private static final byte[] localhostAddress = { 127, 0, 0, 1 };
|
private static final byte[] localhostAddress = { 127, 0, 0, 1 };
|
||||||
|
|
||||||
@ -629,28 +623,28 @@ public class InetAddress implements Serializable
|
|||||||
* @exception UnknownHostException If no IP address for the host could
|
* @exception UnknownHostException If no IP address for the host could
|
||||||
* be found
|
* be found
|
||||||
*/
|
*/
|
||||||
public static InetAddress getLocalHost() throws UnknownHostException
|
public static InetAddress getLocalHost () throws UnknownHostException
|
||||||
{
|
{
|
||||||
SecurityManager s = System.getSecurityManager();
|
SecurityManager s = System.getSecurityManager ();
|
||||||
|
|
||||||
// Experimentation shows that JDK1.2 does cache the result.
|
// Experimentation shows that JDK1.2 does cache the result.
|
||||||
// However, if there is a security manager, and the cached result
|
// However, if there is a security manager, and the cached result
|
||||||
// is other than "localhost", we need to check again.
|
// is other than "localhost", we need to check again.
|
||||||
if (localhost == null
|
if (localhost == null
|
||||||
|| (s != null && localhost.addr != localhostAddress))
|
|| (s != null && localhost.addr != localhostAddress))
|
||||||
getLocalHost(s);
|
getLocalHost (s);
|
||||||
|
|
||||||
return localhost;
|
return localhost;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static synchronized void getLocalHost(SecurityManager s)
|
private static synchronized void getLocalHost (SecurityManager s)
|
||||||
throws UnknownHostException
|
throws UnknownHostException
|
||||||
{
|
{
|
||||||
// Check the localhost cache again, now that we've synchronized.
|
// Check the localhost cache again, now that we've synchronized.
|
||||||
if (s == null && localhost != null)
|
if (s == null && localhost != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String hostname = getLocalHostname();
|
String hostname = getLocalHostname ();
|
||||||
|
|
||||||
if (s != null)
|
if (s != null)
|
||||||
{
|
{
|
||||||
@ -664,7 +658,7 @@ public class InetAddress implements Serializable
|
|||||||
{
|
{
|
||||||
// This is wrong, if the name returned from getLocalHostname()
|
// This is wrong, if the name returned from getLocalHostname()
|
||||||
// is not a fully qualified name. FIXME.
|
// is not a fully qualified name. FIXME.
|
||||||
s.checkConnect(hostname, -1);
|
s.checkConnect (hostname, -1);
|
||||||
}
|
}
|
||||||
catch (SecurityException ex)
|
catch (SecurityException ex)
|
||||||
{
|
{
|
||||||
@ -676,8 +670,8 @@ public class InetAddress implements Serializable
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
localhost = new InetAddress(null, null);
|
localhost = new InetAddress (null, null);
|
||||||
lookup(hostname, localhost, false);
|
lookup (hostname, localhost, false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -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
|
|||||||
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
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* 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
|
|||||||
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
|
|||||||
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;
|
|||||||
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
|
|||||||
*/
|
*/
|
||||||
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
|
|||||||
* 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
|
|||||||
* @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;
|
||||||
|
Loading…
Reference in New Issue
Block a user