Class prominence.url.HTTPURLConnection
All Packages Class Hierarchy This Package Previous Next Index
Class prominence.url.HTTPURLConnection
java.lang.Object
|
+----java.net.URLConnection
|
+----prominence.url.HTTPURLConnection
- public class HTTPURLConnection
- extends URLConnection
An URLConnection that implements a small part of the HTTP protocol.
Supports read-only requests (GET), and no redirects or error responses.
-
headers
- A Hashtable of response-header key/value pairs.
-
in
- An InputStream from which the server response is read.
-
keys
- A Vector of response-header keys.
-
HTTPURLConnection(URL)
- Creates a new HTTPURLConnection attached to a specified URL.
-
connect()
- Connects to the server specified in the constructor if not already
connected, issues an HTTP request and reads the response headers.
-
getContentType()
- Attempts to determine the content-type of the referenced object.
-
getHeaderField(int)
- Returns the requested header value.
-
getHeaderField(String)
- Returns the requested header value.
-
getHeaderFieldKey(int)
- Returns the requested header key.
-
getInputStream()
- Connects to the server if necessary, and returns a stream from which the
response body can be read.
-
readHeaders(InputStream)
- Reads response headers from the server.
-
sendRequest(OutputStream)
- Sends a HTTP/1.0 request to the server.
keys
protected Vector keys
- A Vector of response-header keys.
headers
protected Hashtable headers
- A Hashtable of response-header key/value pairs.
in
protected InputStream in
- An InputStream from which the server response is read.
HTTPURLConnection
public HTTPURLConnection(URL url)
- Creates a new HTTPURLConnection attached to a specified URL.
- Parameters:
- url - The URL to connect to
connect
public void connect() throws IOException
- Connects to the server specified in the constructor if not already
connected, issues an HTTP request and reads the response headers.
Does not examine the HTTP response code or support fallback to HTTP/0.9.
the Socket connection remains open for the response body to be
read.
- Overrides:
- connect in class URLConnection
- See Also:
- sendRequest, readHeaders
sendRequest
protected void sendRequest(OutputStream o) throws IOException
- Sends a HTTP/1.0 request to the server.
- Parameters:
- o - A stream connection to the server
readHeaders
protected void readHeaders(InputStream i) throws IOException
- Reads response headers from the server.
Headers are considered to be all response lines up until a blank line is read.
Key/value responses are inserted in the keys and headers data
structures.
- Parameters:
- i - A stream connection from the server
getInputStream
public InputStream getInputStream() throws IOException
- Connects to the server if necessary, and returns a stream from which the
response body can be read. Headers have already been removed.
- Returns:
- s A stream from which the response body can be read
- Overrides:
- getInputStream in class URLConnection
getContentType
public String getContentType()
- Attempts to determine the content-type of the referenced object.
This may require a connection to be made to the server.
- Returns:
- s The content-type of the Object, or null if it could not be determined
- Overrides:
- getContentType in class URLConnection
getHeaderFieldKey
public String getHeaderFieldKey(int n)
- Returns the requested header key.
- Parameters:
- n - The index of the desired header key, starting from 0
- Returns:
- s The requested key or null
- Overrides:
- getHeaderFieldKey in class URLConnection
getHeaderField
public String getHeaderField(int n)
- Returns the requested header value.
- Parameters:
- n - The index of the desired header value, starting from 0
- Returns:
- s The requested value or null
- Overrides:
- getHeaderField in class URLConnection
getHeaderField
public String getHeaderField(String k)
- Returns the requested header value.
- Parameters:
- k - The key name of the desired header value
- Returns:
- s The requested value or null
- Overrides:
- getHeaderField in class URLConnection
All Packages Class Hierarchy This Package Previous Next Index