1 |
/* Handler.java -- HTTP protocol handler for java.net |
/* Handler.java -- HTTP protocol handler for java.net |
2 |
Copyright (c) 1998 Free Software Foundation, Inc. |
Copyright (c) 1998, 2003 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
37 |
|
|
38 |
package gnu.java.net.protocol.http; |
package gnu.java.net.protocol.http; |
39 |
|
|
40 |
|
import java.io.IOException; |
41 |
import java.net.URL; |
import java.net.URL; |
42 |
import java.net.URLStreamHandler; |
import java.net.URLStreamHandler; |
43 |
import java.net.URLConnection; |
import java.net.URLConnection; |
|
import java.io.IOException; |
|
44 |
|
|
45 |
/** |
/** |
46 |
* This is the protocol handler for the HTTP protocol. It implements |
* This is the protocol handler for the HTTP protocol. It implements |
47 |
* the abstract openConnection() method from URLStreamHandler by returning |
* the abstract openConnection() method from URLStreamHandler by returning |
48 |
* a new HttpURLConnection object (from this package). All other |
* a new HttpURLConnection object (from this package). All other |
49 |
* methods are inherited |
* methods are inherited |
50 |
* |
* |
51 |
* @version 0.1 |
* @author Aaron M. Renn (arenn@urbanophile.com) |
|
* |
|
|
* @author Aaron M. Renn (arenn@urbanophile.com) |
|
|
*/ |
|
|
public class Handler extends URLStreamHandler |
|
|
{ |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/* |
|
|
* Constructors |
|
52 |
*/ |
*/ |
53 |
|
public class Handler extends URLStreamHandler |
|
/** |
|
|
* A do nothing constructor |
|
|
*/ |
|
|
public |
|
|
Handler() |
|
|
{ |
|
|
; |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/* |
|
|
* Instance Methods |
|
|
*/ |
|
|
|
|
|
/** |
|
|
* This method returs a new HttpURLConnection for the specified URL |
|
|
* |
|
|
* @param url The URL to return a connection for |
|
|
* |
|
|
* @return The URLConnection |
|
|
* |
|
|
* @exception IOException If an error occurs |
|
|
*/ |
|
|
protected URLConnection |
|
|
openConnection(URL url) throws IOException |
|
|
{ |
|
|
return(new gnu.java.net.protocol.http.HttpURLConnection(url)); |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
* Returns the default port for a URL parsed by this handler. |
|
|
*/ |
|
|
protected int getDefaultPort () |
|
54 |
{ |
{ |
55 |
return 80; |
/** |
56 |
} |
* A do nothing constructor |
57 |
|
*/ |
58 |
|
public Handler() |
59 |
|
{ |
60 |
|
} |
61 |
|
|
62 |
|
/** |
63 |
|
* This method returs a new HttpURLConnection for the specified URL |
64 |
|
* |
65 |
|
* @param url The URL to return a connection for |
66 |
|
* |
67 |
|
* @return The URLConnection |
68 |
|
* |
69 |
|
* @exception IOException If an error occurs |
70 |
|
*/ |
71 |
|
protected URLConnection openConnection (URL url) throws IOException |
72 |
|
{ |
73 |
|
return new gnu.java.net.protocol.http.HttpURLConnection (url); |
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
|
* Returns the default port for a URL parsed by this handler. |
78 |
|
*/ |
79 |
|
protected int getDefaultPort() |
80 |
|
{ |
81 |
|
return 80; |
82 |
|
} |
83 |
|
|
84 |
} // class Handler |
} // class Handler |
|
|
|