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.


Variable Index

 o headers
A Hashtable of response-header key/value pairs.
 o in
An InputStream from which the server response is read.
 o keys
A Vector of response-header keys.

Constructor Index

 o HTTPURLConnection(URL)
Creates a new HTTPURLConnection attached to a specified URL.

Method Index

 o connect()
Connects to the server specified in the constructor if not already connected, issues an HTTP request and reads the response headers.
 o getContentType()
Attempts to determine the content-type of the referenced object.
 o getHeaderField(int)
Returns the requested header value.
 o getHeaderField(String)
Returns the requested header value.
 o getHeaderFieldKey(int)
Returns the requested header key.
 o getInputStream()
Connects to the server if necessary, and returns a stream from which the response body can be read.
 o readHeaders(InputStream)
Reads response headers from the server.
 o sendRequest(OutputStream)
Sends a HTTP/1.0 request to the server.

Variables

 o keys
  protected Vector keys
A Vector of response-header keys.
 o headers
  protected Hashtable headers
A Hashtable of response-header key/value pairs.
 o in
  protected InputStream in
An InputStream from which the server response is read.

Constructors

 o HTTPURLConnection
  public HTTPURLConnection(URL url)
Creates a new HTTPURLConnection attached to a specified URL.
Parameters:
url - The URL to connect to

Methods

 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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