com.ibm.wbi.http
Class FetchUrl

java.lang.Object
  |
  +--com.ibm.wbi.http.FetchUrl

public class FetchUrl
extends java.lang.Object

This class contains a several static methods for using WBI to open streams to URLs on the web. There are methods that use GET given a URL and methods that take a whole request header to open simple connections. There are also methods that open connections through WBI, thus going through the enabled MEGs.


Constructor Summary
FetchUrl()
           
 
Method Summary
static MegInputStream fetch(HttpRequest request)
          Fetches the contents of the URL specified by the request.
static MegInputStream fetch(HttpRequest request, int timeout)
          Fetches the contents of the URL specified by the request, but connection closes automatically after a time if the fetch is not done.
static MegInputStream fetch(java.lang.String url)
          Fetches the contents of a URL using an HTTP/1.0 'GET'.
static MegInputStream fetch(java.lang.String url, int timeout)
          Fetches the contents of a URL using an HTTP/1.0 'GET', but connection closes automatically after a time if the fetch is not done.
static MegInputStream fetchThroughProxy(RequestEvent originalEvent, HttpRequest request)
          Fetches the contents of a URL based on an HTTP request that describes the desired URL.
static MegInputStream fetchThroughProxy(RequestEvent originalEvent, java.lang.String url)
          Fetches the contents of a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FetchUrl

public FetchUrl()
Method Detail

fetch

public static MegInputStream fetch(java.lang.String url)
                            throws java.io.IOException
Fetches the contents of a URL using an HTTP/1.0 'GET'.
Parameters:
url - The URL to fetch.
Returns:
A stream from which the results may be read.

fetch

public static MegInputStream fetch(java.lang.String url,
                                   int timeout)
                            throws java.io.IOException
Fetches the contents of a URL using an HTTP/1.0 'GET', but connection closes automatically after a time if the fetch is not done.
Parameters:
url - The URL to fetch.
timeout - Number of milliseconds to keep the connection open
Returns:
A stream from which the results may be read.

fetch

public static MegInputStream fetch(HttpRequest request)
                            throws java.io.IOException
Fetches the contents of the URL specified by the request.
Parameters:
request - The request header to be fetched.
Returns:
A stream from which the results may be read.

fetch

public static MegInputStream fetch(HttpRequest request,
                                   int timeout)
                            throws java.io.IOException
Fetches the contents of the URL specified by the request, but connection closes automatically after a time if the fetch is not done.
Parameters:
request - The request header to be fetched.
timeout - Number of milliseconds to keep the connection open
Returns:
A stream from which the results may be read.

fetchThroughProxy

public static MegInputStream fetchThroughProxy(RequestEvent originalEvent,
                                               java.lang.String url)
                                        throws java.io.IOException
Fetches the contents of a URL. The contents are fetched with an HTTP/1.0 'GET' request with no other details (such as user-agent, etc.) in the HTTP header. The fetch is done through the proxy, so it will be handled by the same chain of MEGs as if the request had come to the proxy from a browser.
Parameters:
originalEvent - This is the event that launched the MEG that is calling this method. (I.e. if a Generator was called with RequestEvent event and that Generator decides it needs to fetch the contents of a URL in order to complete its work, then that Generator must pass event here so that the correct RequestManager can be used to process the request through the proxy.
url - The URL to fetch.
Returns:
A stream from which the results may be read.

fetchThroughProxy

public static MegInputStream fetchThroughProxy(RequestEvent originalEvent,
                                               HttpRequest request)
                                        throws java.io.IOException
Fetches the contents of a URL based on an HTTP request that describes the desired URL. The fetch is done through the proxy, so it will be handled by the same chain of MEGs as if the request had come to the proxy from a browser.
Parameters:
originalEvent - This is the event that launched the MEG that is calling this method. (I.e. if a Generator was called with RequestEvent event and that Generator decides it needs to fetch the contents of a URL in order to complete its work, then that Generator must pass event here so that the correct RequestManager can be used to process the request through the proxy.
request - This request contains the HTTP request which asks for the needed URL.
Returns:
A stream from which the results may be read.