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>
* 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
(InflaterInputStream): Throw NullPointerException if in is null (as
JDK does).
......
// HttpURLConnection.java - Subclass of communications links using
// Hypertext Transfer Protocol.
/* Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation
/* HttpURLConnection.java - Subclass of communications links using
Hypertext Transfer Protocol.
Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation
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
exception statement from your version. */
package java.net;
import java.io.*;
import java.io.InputStream;
import java.io.IOException;
import java.io.PushbackInputStream;
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
exception statement from your version. */
package java.net;
import java.io.IOException;
import java.io.ObjectStreamException;
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
exception statement from your version. */
package java.net;
import java.io.IOException;
import java.util.Arrays;
/**
......
......@@ -157,57 +157,11 @@ public class ServerSocket
if (impl == null)
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
impl.create(true);
// bind to address/port
try
{
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;
}
// bind/listen socket
bind (new InetSocketAddress (bindAddr, port), backlog);
}
/**
......@@ -258,9 +212,48 @@ public class ServerSocket
if (s != null)
s.checkListen (tmp.getPort ());
// bind to address/port
try
{
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);
}
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
......
/* 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.
......@@ -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
exception statement from your version. */
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.
* 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
exception statement from your version. */
package java.net;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilterInputStream;
import java.io.FilePermission;
import java.io.InputStream;
import java.io.IOException;
......@@ -60,7 +59,6 @@ import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.zip.ZipException;
/**
* 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)
{
String str = getHeaderField(name);
int result = defaultValue;
String value = getHeaderField (name);
if (value == null)
return defaultValue;
try
{
if (str != null)
result = Integer.parseInt (str);
return Integer.parseInt (value);
}
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.
*
* @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
* if the field is missing or malformed
*/
public long getHeaderFieldDate(String name, long val)
public long getHeaderFieldDate (String name, long defaultValue)
{
if (! dateformats_initialized)
initializeDateFormats();
String str = getHeaderField(name);
initializeDateFormats ();
long result = defaultValue;
String str = getHeaderField (name);
if (str != null)
{
Date date;
if ((date = dateFormat1.parse(str, new ParsePosition(0))) != null)
val = date.getTime();
else if ((date = dateFormat2.parse(str, new ParsePosition(0))) != null)
val = date.getTime();
else if ((date = dateFormat3.parse(str, new ParsePosition(0))) != null)
val = date.getTime();
Date date;
if ((date = dateFormat1.parse (str, new ParsePosition (0))) != null)
result = date.getTime ();
else if ((date = dateFormat2.parse (str, new ParsePosition (0))) != null)
result = date.getTime ();
else if ((date = dateFormat3.parse (str, new ParsePosition (0))) != null)
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
* of the headers.
*/
public String getHeaderFieldKey(int index)
public String getHeaderFieldKey (int index)
{
// Subclasses for specific protocols override this.
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