org.lobobrowser.html.test

Class SimpleHttpRequest

Implemented Interfaces:
HttpRequest

public class SimpleHttpRequest
extends java.lang.Object
implements HttpRequest

The SimpleHttpRequest class implements the HttpRequest interface. The HttpRequest implementation provided by this class is simple, with no caching. It creates a new thread for each new asynchronous request.
Author:
J. H. S.

Field Summary

protected java.net.URLConnection
connection
The URLConnection is assigned to this field while it is ongoing.
protected String
responseHeaders
Response headers are set in this string after a response is received.
protected Map
responseHeadersMap
Response headers are set in this map after a response is received.

Fields inherited from interface org.lobobrowser.html.HttpRequest

STATE_COMPLETE, STATE_INTERACTIVE, STATE_LOADED, STATE_LOADING, STATE_UNINITIALIZED

Constructor Summary

SimpleHttpRequest(UserAgentContext context, java.net.Proxy proxy)

Method Summary

void
abort()
void
addReadyStateChangeListener(ReadyStateChangeListener listener)
String
getAllResponseHeaders()
int
getReadyState()
byte[]
getResponseBytes()
String
getResponseHeader(String headerName)
Image
getResponseImage()
String
getResponseText()
Document
getResponseXML()
int
getStatus()
String
getStatusText()
void
open(String method, String url)
void
open(String method, String url, boolean asyncFlag)
void
open(String method, String url, boolean asyncFlag, String userName)
void
open(String method, String url, boolean asyncFlag, String userName, String password)
void
open(String method, URL url)
void
open(String method, URL url, boolean asyncFlag)
void
open(String method, java.net.URL url, boolean asyncFlag, String userName, String password)
Opens the request by invoking openSync(String, URL, String, String).
protected void
openSync(String method, java.net.URL url, String userName, String password)
This method performs a synchronous URL connection.

Field Details

connection

protected java.net.URLConnection connection
The URLConnection is assigned to this field while it is ongoing.

responseHeaders

protected String responseHeaders
Response headers are set in this string after a response is received.

responseHeadersMap

protected Map responseHeadersMap
Response headers are set in this map after a response is received.

Constructor Details

SimpleHttpRequest

public SimpleHttpRequest(UserAgentContext context,
                         java.net.Proxy proxy)

Method Details

abort

public void abort()
Specified by:
abort in interface HttpRequest

addReadyStateChangeListener

public void addReadyStateChangeListener(ReadyStateChangeListener listener)
Specified by:
addReadyStateChangeListener in interface HttpRequest

getAllResponseHeaders

public String getAllResponseHeaders()
Specified by:
getAllResponseHeaders in interface HttpRequest

getReadyState

public int getReadyState()
Specified by:
getReadyState in interface HttpRequest

getResponseBytes

public byte[] getResponseBytes()
Specified by:
getResponseBytes in interface HttpRequest

getResponseHeader

public String getResponseHeader(String headerName)
Specified by:
getResponseHeader in interface HttpRequest

getResponseImage

public Image getResponseImage()
Specified by:
getResponseImage in interface HttpRequest

getResponseText

public String getResponseText()
Specified by:
getResponseText in interface HttpRequest

getResponseXML

public Document getResponseXML()
Specified by:
getResponseXML in interface HttpRequest

getStatus

public int getStatus()
Specified by:
getStatus in interface HttpRequest

getStatusText

public String getStatusText()
Specified by:
getStatusText in interface HttpRequest

open

public void open(String method,
                 String url)
Specified by:
open in interface HttpRequest

open

public void open(String method,
                 String url,
                 boolean asyncFlag)
Specified by:
open in interface HttpRequest

open

public void open(String method,
                 String url,
                 boolean asyncFlag,
                 String userName)
Specified by:
open in interface HttpRequest

open

public void open(String method,
                 String url,
                 boolean asyncFlag,
                 String userName,
                 String password)
Specified by:
open in interface HttpRequest

open

public void open(String method,
                 URL url)
Specified by:
open in interface HttpRequest

open

public void open(String method,
                 URL url,
                 boolean asyncFlag)
Specified by:
open in interface HttpRequest

open

public void open(String method,
                 java.net.URL url,
                 boolean asyncFlag,
                 String userName,
                 String password)
Opens the request by invoking openSync(String, URL, String, String). For asynchronous requests, a new thread is created before proceeding.
Parameters:
method - The request method.
url - The request URL.
asyncFlag - Whether the request should be asynchronous.
userName - The user name of the request (not supported.)
password - The password of the request (not supported.)

openSync

protected void openSync(String method,
                        java.net.URL url,
                        String userName,
                        String password)
This method performs a synchronous URL connection. It may be overridden.
Parameters:
method - The request method.
url - The request URL.
userName - An optional username.
password - An optional password.