|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.mwi.mobileok.basic.HTTPResource
public abstract class HTTPResource
Abstract class that encapsulates information and basic functionality to represent resources that are retrieved using HTTP (or HTTPS).
The information includes the headers returned in the HTTP(S) Response as well as the body of the response and any intermediary redirection that might have been required to retrieved the resource from its initial URI.
The HTTP resource is retrieved when the instance is created. Since there is no way to ensure that the retrieval will take a given amount of time, the instanciation of the class may thus take more than a minute.
The HTTP request sent to retrieve the HTTP resource contains precise HTTP header fields that identify the mobileOK Checker. The specific values are hard-coded in the class, and defined in the W3C mobileOK Basic Tests 1.0 standard. They are:
User-Agent: W3C-mobileOK/DDC-1.0 (see http://www.w3.org/2006/07/mobileok-ddc)
Accept: application/xhtml+xml,text/html;q=0.1,application/vnd.wap.xhtml+xml;q=0.1,text/css,image/jpeg,image/gif
Accept-Charset: UTF-8
The final HTTP status code is accessible through the getStatusCode()
method. A network error is represented by the specific status
HTTPRedirect.NETWORK_ERROR
.
The final response is accessible through the getLastRedirect()
method. When a network error occurred, a fake HTTPRedirect
instance
is created (with status code HTTPRedirect.NETWORK_ERROR
).
If the scheme of the resource's URI is HTTPS, the MobileOKSSLProtocolSocketFactory
and the MobileOKTrustManager
classes are used to create and check
the secure socket. The final HTTPS outcome is accessible through the
corresponding HTTPRedirect
instance and the
HTTPRedirect.getHttpsError()
method.
The class does not contain any abstract method per se. The class is
defined as abstract to emphasize the fact that the Checker never deals
with generic HTTP/HTTPS resources in practice, but rather with specific
HTTPCSSResource
, HTTPXHTMLResource
, HTTPImageResource
,
etc.
Constructor Summary | |
---|---|
HTTPResource(java.net.URI uri)
|
|
HTTPResource(java.net.URI uri,
java.util.Map<java.lang.String,java.lang.String> additionalRequestHeaders)
|
Method Summary | |
---|---|
(package private) static void |
configureHTTPMethod(org.apache.commons.httpclient.HttpMethod method,
java.util.Map<java.lang.String,java.lang.String> additionalRequestHeaders)
|
(package private) static void |
executeMethod(org.apache.commons.httpclient.HttpMethod method)
|
(package private) HTTPRedirect |
getLastRedirect()
|
(package private) org.apache.commons.httpclient.Header[] |
getRawRequestHeaders()
|
(package private) byte[] |
getRawResponseBody()
|
(package private) org.apache.commons.httpclient.Header[] |
getRawResponseHeaders()
|
(package private) HTTPRedirect |
getRedirect(int redirect)
|
(package private) int |
getRedirectCount()
|
(package private) java.util.Map<java.lang.String,java.lang.String> |
getRequestHeaders()
|
(package private) java.util.Map<java.lang.String,java.lang.String> |
getResponseHeaders()
|
(package private) java.lang.String |
getResponseProtocol()
|
(package private) java.lang.String |
getResponseReason()
|
(package private) int |
getResponseStatus()
|
int |
getStatusCode()
|
java.net.URI |
getURI()
|
java.lang.String |
getURI(int redirect)
|
(package private) static boolean |
isValidDateHeader(java.lang.String dateHeader)
|
static boolean |
isValidExpirationDate(java.lang.String currentDateStr,
java.lang.String expirationDateStr)
|
(package private) static java.net.URI |
massageURI(java.net.URI uri)
|
(package private) static java.net.URI |
parseURI(java.net.URI baseURI,
java.lang.String uriString)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HTTPResource(java.net.URI uri) throws TestException
TestException
public HTTPResource(java.net.URI uri, java.util.Map<java.lang.String,java.lang.String> additionalRequestHeaders) throws TestException
TestException
Method Detail |
---|
static java.net.URI massageURI(java.net.URI uri)
static void configureHTTPMethod(org.apache.commons.httpclient.HttpMethod method, java.util.Map<java.lang.String,java.lang.String> additionalRequestHeaders)
static void executeMethod(org.apache.commons.httpclient.HttpMethod method) throws java.io.IOException
java.io.IOException
final int getRedirectCount()
public final int getStatusCode()
public final java.net.URI getURI()
public final java.lang.String getURI(int redirect)
final HTTPRedirect getRedirect(int redirect)
final HTTPRedirect getLastRedirect()
final org.apache.commons.httpclient.Header[] getRawRequestHeaders()
final java.util.Map<java.lang.String,java.lang.String> getRequestHeaders()
final org.apache.commons.httpclient.Header[] getRawResponseHeaders()
final java.util.Map<java.lang.String,java.lang.String> getResponseHeaders()
final int getResponseStatus()
final java.lang.String getResponseProtocol()
final java.lang.String getResponseReason()
final byte[] getRawResponseBody()
public static boolean isValidExpirationDate(java.lang.String currentDateStr, java.lang.String expirationDateStr)
static boolean isValidDateHeader(java.lang.String dateHeader)
static java.net.URI parseURI(java.net.URI baseURI, java.lang.String uriString)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |