Kafenio.editor 0.8.5

de.xeinfach.kafenio.urlfetch
Class URLFetch

java.lang.Object
  extended byde.xeinfach.kafenio.urlfetch.URLFetch

public class URLFetch
extends java.lang.Object

Description: Fetches content from URLs

Author:
Todd Wilson, modified by Karsten Pawlik

Constructor Summary
URLFetch()
           
 
Method Summary
 void addHeader(HTTPHeader header)
          Adds a request header to be sent to the server.
 void fetch()
          Issues the request to the server.
 void flushHeaders()
          Flushes any existing headers out, excluding cookies.
 int getHTTPStatusCode()
          Gets the code portion of the HTTP status.
 java.lang.String getPOSTData()
          Gets the POST data.
 java.net.URL getRedirectURL()
          In the case of a redirect, gets the URL to go to.
 HTTPHeader getRequestHeader(java.lang.String name)
          Gets a request header by name.
 java.util.HashSet getRequestHeaders()
          Returns the HTTP request headers.
 java.lang.String getRequestLine()
          Returns the first line of the request.
 java.lang.String getRequestMethod()
          Returns the request method used.
 byte[] getResponseBody()
          If a binary file was fetched, this function will return it as a byte array.
 HTTPHeader getResponseHeader(java.lang.String name)
          Gets a response header by name.
 java.util.HashSet getResponseHeaders()
          Returns the HTTP headers received from the server.
 java.lang.String getResponseStatus()
          Returns the HTTP status of a response.
 java.net.URL getURL()
          Gets the URL to be fetched.
 void setAuthorization(java.lang.String newAuthorizationUsername, java.lang.String newAuthorizationPassword)
          Sets authorization tokens in the case of BASIC authentication
 void setPOSTData(java.lang.String newPostData)
          Sets the POST data.
 void setProxyHost(java.lang.String newProxyHost)
          Sets the host of the proxy, if one is needed.
 void setProxyPassword(java.lang.String newProxyPassword)
          Sets the password of the proxy, if one is needed.
 void setProxyPort(int newProxyPort)
          Sets the port of the proxy, if one is needed.
 void setResponseStatus(java.lang.String newResponseStatus)
          Sets the HTTP status of a response.
 void setURL(java.net.URL newUrl)
          Sets the URL to be fetched.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLFetch

public URLFetch()
Method Detail

fetch

public void fetch()
           throws java.io.IOException
Issues the request to the server.

Throws:
java.io.IOException - an IOException

flushHeaders

public void flushHeaders()
Flushes any existing headers out, excluding cookies.


getURL

public java.net.URL getURL()
Gets the URL to be fetched.

Returns:
The URL.

setURL

public void setURL(java.net.URL newUrl)
Sets the URL to be fetched.

Parameters:
newUrl - The URL.

setPOSTData

public void setPOSTData(java.lang.String newPostData)
Sets the POST data.

Parameters:
newPostData - The POST data.

getPOSTData

public java.lang.String getPOSTData()
Gets the POST data.

Returns:
The POST data.

getResponseHeader

public HTTPHeader getResponseHeader(java.lang.String name)
Gets a response header by name.

Parameters:
name - The name of the desired header.
Returns:
returns a HTTPHeader object.

getRedirectURL

public java.net.URL getRedirectURL()
In the case of a redirect, gets the URL to go to. Often servers will send a relative path to redirect to. This method handles turning that relative URL into an absolute one.

Returns:
The URL to redirect to.

getRequestHeaders

public java.util.HashSet getRequestHeaders()
Returns the HTTP request headers.

Returns:
The headers.

getRequestHeader

public HTTPHeader getRequestHeader(java.lang.String name)
Gets a request header by name.

Parameters:
name - The name of the desired header.
Returns:
returns a HTTPHeader object.

getRequestMethod

public java.lang.String getRequestMethod()
Returns the request method used.

Returns:
The method (only GET or POST).

getRequestLine

public java.lang.String getRequestLine()
Returns the first line of the request.

Returns:
The first line.

getResponseHeaders

public java.util.HashSet getResponseHeaders()
Returns the HTTP headers received from the server.

Returns:
The headers.

setAuthorization

public void setAuthorization(java.lang.String newAuthorizationUsername,
                             java.lang.String newAuthorizationPassword)
Sets authorization tokens in the case of BASIC authentication

Parameters:
newAuthorizationUsername - The username.
newAuthorizationPassword - The password.

addHeader

public void addHeader(HTTPHeader header)
Adds a request header to be sent to the server.

Parameters:
header - The header to be sent in the request.

getResponseBody

public byte[] getResponseBody()
If a binary file was fetched, this function will return it as a byte array.

Returns:
returns the response body as byte-array.

getResponseStatus

public java.lang.String getResponseStatus()
Returns the HTTP status of a response.

Returns:
The status.

setResponseStatus

public void setResponseStatus(java.lang.String newResponseStatus)
Sets the HTTP status of a response.

Parameters:
newResponseStatus - The status.

getHTTPStatusCode

public int getHTTPStatusCode()
Gets the code portion of the HTTP status.

Returns:
An int representing the status code.

setProxyHost

public void setProxyHost(java.lang.String newProxyHost)
Sets the host of the proxy, if one is needed.

Parameters:
newProxyHost - The host.

setProxyPort

public void setProxyPort(int newProxyPort)
Sets the port of the proxy, if one is needed.

Parameters:
newProxyPort - The port.

setProxyPassword

public void setProxyPassword(java.lang.String newProxyPassword)
Sets the password of the proxy, if one is needed.

Parameters:
newProxyPassword - The password.

Kafenio.editor 0.8.5

Copyright © 2003-2004 by Karsten Pawlik. All Rights Reserved. Published under the Lesser General Public License (LGPL)