|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.mwi.mobileok.basic.HttpResourceRetriever
public class HttpResourceRetriever
Resource retriever that handles the HTTP scheme.
Field Summary | |
---|---|
private static org.apache.commons.httpclient.HttpClient |
client
HTTP client used to retrieve HTTP resources. |
static java.lang.String |
CONFIG_HTTP_ACCEPT_CHARSET_HEADER
Name of the configuration key to use in TesterConfiguration
to override the Accept-Charset HTTP header sent to retrieve
the resource. |
static java.lang.String |
CONFIG_HTTP_ACCEPT_HEADER
Name of the configuration key to use in TesterConfiguration
to override the Accept HTTP header sent to retrieve
the resource. |
static java.lang.String |
CONFIG_HTTP_ADDITIONAL_HEADERS
Name of the configuration key to use in TesterConfiguration
to send additional HTTP header fields in the request. |
static java.lang.String |
CONFIG_HTTP_PROXY_HOST
Hostname of the proxy to use when sending HTTP requests. |
static java.lang.String |
CONFIG_HTTP_PROXY_PORT
Port of the proxy to use when sending HTTP requests. |
static java.lang.String |
CONFIG_HTTP_UA_HEADER
Name of the configuration key to use in TesterConfiguration
to override the User-Agent HTTP header sent to retrieve
the resource. |
private static int |
MAX_REDIRECTS
Maximum number of redirects before giving up. |
private static java.lang.String |
MOBILEOK_ACCEPT_CHARSET_HEADER
mobileOK value of the Accept-Charset HTTP header field. |
private static java.lang.String |
MOBILEOK_ACCEPT_HEADER
mobileOK value of the Accept HTTP header field. |
private static java.lang.String |
MOBILEOK_UA
mobileOK value of the User-Agent HTTP header field. |
Constructor Summary | |
---|---|
HttpResourceRetriever()
|
Method Summary | |
---|---|
static void |
configureHTTPMethod(org.apache.commons.httpclient.HttpMethod method,
java.util.Map<java.lang.String,java.lang.String> additionalRequestHeaders)
Prepares the HTTP request to send. |
static void |
executeMethod(org.apache.commons.httpclient.HttpMethod method)
Sends the HTTP request and retrieves the response. |
java.util.List<RetrievalElement> |
getResource(java.net.URI uri)
Retrieves the Web resource identified by the URI. |
private static boolean |
isAuthorizationStatus(int status)
Returns true when the HTTP status code is an "authorization required" status. |
private static boolean |
isRedirectStatus(int status)
Returns true when the HTTP status code is a "redirection" status. |
boolean |
isSchemeSupported(java.net.URI uri)
Returns true when the scheme of the given URI is supported
by the resource retriever. |
private static boolean |
manageBasicAuthentification(org.apache.commons.httpclient.HttpMethod method)
Registers user's credentials that may have been set in TesterConfiguration in the HttpClient instance used to
retrieve the resource. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int MAX_REDIRECTS
private static final java.lang.String MOBILEOK_UA
This value is used by default unless overridden in
TesterConfiguration
.
private static final java.lang.String MOBILEOK_ACCEPT_HEADER
This value is used by default unless overridden in
TesterConfiguration
.
private static final java.lang.String MOBILEOK_ACCEPT_CHARSET_HEADER
This value is used by default unless overridden in
TesterConfiguration
.
public static final java.lang.String CONFIG_HTTP_UA_HEADER
TesterConfiguration
to override the User-Agent
HTTP header sent to retrieve
the resource.
public static final java.lang.String CONFIG_HTTP_ACCEPT_HEADER
TesterConfiguration
to override the Accept
HTTP header sent to retrieve
the resource.
public static final java.lang.String CONFIG_HTTP_ACCEPT_CHARSET_HEADER
TesterConfiguration
to override the Accept-Charset
HTTP header sent to retrieve
the resource.
public static final java.lang.String CONFIG_HTTP_ADDITIONAL_HEADERS
TesterConfiguration
to send additional HTTP header fields in the request.
public static final java.lang.String CONFIG_HTTP_PROXY_HOST
public static final java.lang.String CONFIG_HTTP_PROXY_PORT
private static final org.apache.commons.httpclient.HttpClient client
Constructor Detail |
---|
public HttpResourceRetriever()
Method Detail |
---|
public java.util.List<RetrievalElement> getResource(java.net.URI uri)
ResourceRetriever
The exact class of the returned RetrievalElement
elements may
depend on the scheme and Content-Type of the resource being retrieved.
getResource
in interface ResourceRetriever
uri
- Absolute URI of the Web resource to retrieve
null
when the
scheme of the URI is not supported.public boolean isSchemeSupported(java.net.URI uri)
ResourceRetriever
true
when the scheme of the given URI is supported
by the resource retriever.
isSchemeSupported
in interface ResourceRetriever
uri
- Absolute URI of the Web resource to check
true
when the scheme is supported,
false
otherwise.public static void configureHTTPMethod(org.apache.commons.httpclient.HttpMethod method, java.util.Map<java.lang.String,java.lang.String> additionalRequestHeaders)
Note the function needs to access the tester configuration per-thread singleton. Since retrieval is typically done using multithreading, make sure the singleton is set in the thread that calls this function!
method
- HTTP exchange to completeadditionalRequestHeaders
- potential additional HTTP headers to set
in the request. Cannot be null
.private static boolean manageBasicAuthentification(org.apache.commons.httpclient.HttpMethod method) throws TestException
TesterConfiguration
in the HttpClient
instance used to
retrieve the resource.
Note the function needs to access the tester configuration per-thread singleton. Since retrieval is typically done using multithreading, make sure the singleton is set in the thread that calls this function!
method
- the HTTP exchange that requires authentication.
true
when credentials could be set,
false
otherwise.
TestException
private static boolean isRedirectStatus(int status)
status
- HTTP response status code to parse.
private static boolean isAuthorizationStatus(int status)
status
- HTTP response status code to parse.
public static void executeMethod(org.apache.commons.httpclient.HttpMethod method) throws java.io.IOException
Note the function needs to access the tester configuration per-thread singleton. Since retrieval is typically done using multithreading, make sure the singleton is set in the thread that calls this function!
method
- prepared HTTP exchange.
java.io.IOException
- a network error occurred.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |