net.spy.net
Class HTTPFetch

java.lang.Object
  extended by net.spy.net.HTTPFetch

public class HTTPFetch
extends java.lang.Object

Oversimplified HTTP document fetcher.


Constructor Summary
HTTPFetch(java.net.URL u)
          Get an HTTPFetch instance for the given URL.
HTTPFetch(java.net.URL u, java.util.Map<java.lang.String,java.util.List<java.lang.String>> head)
          Get an HTTPFetch instance for the given URL and headers.
 
Method Summary
 java.lang.String getData()
          Return the contents of the URL as a whole string.
 long getLastModified()
          Get the last modified date of this response.
 java.util.List<java.lang.String> getLines()
          Get a vector containing the individual lines of the document returned from the URL.
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
          Get the response headers from the request (will force a content fetch).
 int getStatus()
          Get the HTTP status from this request.
 java.lang.String getStrippedData()
          Return the contents of the URL with the HTML tags stripped out.
static void main(java.lang.String[] args)
           
 void setIfModifiedSince(long to)
          Set the ifModifiedSince value for the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPFetch

public HTTPFetch(java.net.URL u)
Get an HTTPFetch instance for the given URL.

Parameters:
u - the URL to fetch

HTTPFetch

public HTTPFetch(java.net.URL u,
                 java.util.Map<java.lang.String,java.util.List<java.lang.String>> head)
Get an HTTPFetch instance for the given URL and headers.

Parameters:
u - URL to fetch
head - Map containing the headers to fetch
Method Detail

getResponseHeaders

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
                                                                                    throws java.io.IOException
Get the response headers from the request (will force a content fetch).

Throws:
java.io.IOException

setIfModifiedSince

public void setIfModifiedSince(long to)
Set the ifModifiedSince value for the request.


getStatus

public int getStatus()
              throws java.io.IOException
Get the HTTP status from this request.

Throws:
java.io.IOException

getLastModified

public long getLastModified()
                     throws java.io.IOException
Get the last modified date of this response.

Throws:
java.io.IOException

getLines

public java.util.List<java.lang.String> getLines()
                                          throws java.io.IOException
Get a vector containing the individual lines of the document returned from the URL.

Throws:
java.io.IOException - thrown when something fails.

getData

public java.lang.String getData()
                         throws java.io.IOException
Return the contents of the URL as a whole string.

Returns:
the contents from the URL as a String
Throws:
java.io.IOException - if there is a problem accessing the URL

getStrippedData

public java.lang.String getStrippedData()
                                 throws java.lang.Exception
Return the contents of the URL with the HTML tags stripped out.

Throws:
java.lang.Exception - thrown when something fails.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.