org.w3c.jigsaw.http
Class Request

java.lang.Object
  extended by org.w3c.www.http.HttpMessage
      extended by org.w3c.www.http.HttpEntityMessage
          extended by org.w3c.www.http.HttpRequestMessage
              extended by org.w3c.jigsaw.http.Request
All Implemented Interfaces:
java.lang.Cloneable, RequestInterface, HTTP, MimeHeaderHolder
Direct Known Subclasses:
DAVRequest

public class Request
extends HttpRequestMessage
implements RequestInterface

this class extends HttpRequestMessage to cope with HTTP request. One subtely here: note how each field acessor never throws an exception, but rather is provided with a default value: this is in the hope that sometime, HTTP will not require all the parsing it requires right now.


Field Summary
protected  Client client
           
protected  ResourceFilter[] filters
           
protected  java.io.InputStream in
           
protected  int infilters
           
protected  boolean internal
           
protected  boolean keepcon
           
static java.lang.String ORIG_URL_STATE
          the state of original URL
protected  Request original
           
protected  MimeParser parser
           
static java.net.URL THE_SERVER
          The URL that means * for an OPTIONS method.
 
Fields inherited from class org.w3c.www.http.HttpRequestMessage
H_ACCEPT, H_ACCEPT_CHARSET, H_ACCEPT_ENCODING, H_ACCEPT_LANGUAGE, H_AUTHORIZATION, H_EXPECT, H_FROM, H_HOST, H_IF_MATCH, H_IF_MODIFIED_SINCE, H_IF_NONE_MATCH, H_IF_RANGE, H_IF_UNMODIFIED_SINCE, H_MAX_FORWARDS, H_PROXY_AUTHORIZATION, H_RANGE, H_REFERER, H_TE, H_USER_AGENT, method, proxy, sProxy, url
 
Fields inherited from class org.w3c.www.http.HttpEntityMessage
H_ALLOW, H_CONTENT_BASE, H_CONTENT_ENCODING, H_CONTENT_LANGUAGE, H_CONTENT_LENGTH, H_CONTENT_LOCATION, H_CONTENT_MD5, H_CONTENT_RANGE, H_CONTENT_TYPE, H_ETAG, H_EXPIRES, H_LAST_MODIFIED
 
Fields inherited from class org.w3c.www.http.HttpMessage
descriptors, EMIT_ALL, EMIT_BODY, EMIT_FOOTERS, EMIT_HEADERS, emitdate, factory, H_CACHE_CONTROL, H_CMAN_EXT, H_CONNECTION, H_COOKIE, H_COPT_EXT, H_DATE, H_MAN_EXT, H_OPT_EXT, H_PRAGMA, H_PROTOCOL, H_PROTOCOL_INFO, H_PROTOCOL_QUERY, H_PROTOCOL_REQUEST, H_PROXY_CONNECTION, H_SET_COOKIE, H_TRAILER, H_TRANSFER_ENCODING, H_UPGRADE, H_VIA, headers, major, MAX_HEADERS, minor, state, values
 
Fields inherited from interface org.w3c.www.http.HTTP
ACCEPTED, BAD_GATEWAY, BAD_REQUEST, byteArrayVersion, CONFLICT, CONNECT, CONTINUE, CREATED, DELETE, DONE, EXPECTATION_FAILED, FORBIDDEN, FOUND, GATEWAY_TIMEOUT, GET, GONE, HEAD, HTTP_100_CONTINUE, HTTP_VERSION_NOT_SUPPORTED, INTERNAL_SERVER_ERROR, LENGTH_REQUIRED, major_number, minor_number, MOVED_PERMANENTLY, msg_100, msg_200, msg_300, msg_400, msg_500, MULTIPLE_CHOICE, NO_CONTENT, NOHEADER, NON_AUTHORITATIVE_INFORMATION, NOT_ACCEPTABLE, NOT_ALLOWED, NOT_EXTENDED, NOT_FOUND, NOT_IMPLEMENTED, NOT_MODIFIED, OK, OPTIONS, PARTIAL_CONTENT, PAYMENT_REQUIRED, POST, PRECONDITION_FAILED, PROXY_AUTH_REQUIRED, PUT, REQUEST_ENTITY_TOO_LARGE, REQUEST_TIMEOUT, REQUEST_URI_TOO_LONG, REQUESTED_RANGE_NOT_SATISFIABLE, RESET_CONTENT, SEE_OTHER, SERVICE_UNAVAILABLE, SWITCHING, TEMPORARY_REDIRECT, TRACE, UNAUTHORIZED, UNSUPPORTED_MEDIA_TYPE, USE_PROXY
 
Constructor Summary
Request(Client client, MimeParser parser)
           
 
Method Summary
 boolean canKeepConnection()
           
 Client getClient()
          Get the client of this request.
 HttpMessage getClone()
          Clone this request, in order to launch an internal request.
 java.io.InputStream getInputStream()
          Get this reply entity body.
 Request getOriginal()
           
 java.lang.String getQueryString()
           
 ResourceReference getTargetResource()
          Get this request target resource.
 java.lang.String getURLPath()
          Get the URL path of the target resource.
 boolean hasAccept()
           
 boolean hasAcceptCharset()
           
 boolean hasAcceptEncoding()
           
 boolean hasAcceptLanguage()
           
 boolean hasAuthorization()
          Does this request has some specific authorization infos.
 boolean hasContentLength()
           
 boolean hasContentType()
           
 boolean hasProxyAuthorization()
           
 boolean hasQueryString()
           
 boolean isInternal()
          Return true is the request is internal.
 boolean isProxy()
           
 ReplyInterface makeBadRequestReply()
          Get a "Bad request" reply.
 Reply makeReply(int status)
          Make an empty Reply object matching this request version.
 void notifyEndParsing(MimeParser parser)
          Fix the target URL of the request, this is the only good time to do so.
protected  void setFilters(ResourceFilter[] filters, int infilters)
           
 void setInternal(boolean onoff)
           
 void setProxy(boolean onoff)
           
 void setState(java.lang.String name, java.lang.String state)
          FIXME doc
 void setStream(java.io.InputStream is)
          Set this reply entity body.
protected  void setTargetResource(ResourceReference resource)
           
 void setURLPath(java.lang.String path)
           
 void skipBody()
          skip the body
static java.lang.String unescape(java.lang.String s)
          Unescape a HTTP escaped string
 
Methods inherited from class org.w3c.www.http.HttpRequestMessage
dump, getAccept, getAcceptCharset, getAcceptEncoding, getAcceptLanguage, getAuthorization, getExpect, getFrom, getHost, getIfMatch, getIfModifiedSince, getIfNoneMatch, getIfRange, getIfUnmodifiedSince, getMaxForwards, getMaxStale, getMethod, getMinFresh, getProxy, getProxyAuthorization, getRange, getReferer, getTarget, getTE, getURL, getUserAgent, hasProxy, main, notifyBeginParsing, setAccept, setAcceptCharset, setAcceptEncoding, setAcceptLanguage, setAuthorization, setExpect, setFrom, setHost, setIfMatch, setIfModifiedSince, setIfNoneMatch, setIfRange, setIfUnmodifiedSince, setMaxForwards, setMaxStale, setMethod, setMinFresh, setProxy, setProxyAuthorization, setRange, setReferer, setTarget, setTE, setURL, setUserAgent, startEmit
 
Methods inherited from class org.w3c.www.http.HttpEntityMessage
addContentEncoding, getAllow, getContentBase, getContentEncoding, getContentLanguage, getContentLength, getContentLocation, getContentMD5, getContentRange, getContentType, getETag, getExpires, getLastModified, hasContentRange, setAllow, setContentBase, setContentEncoding, setContentLanguage, setContentLength, setContentLocation, setContentMD5, setContentType, setETag, setExpires, setLastModified
 
Methods inherited from class org.w3c.www.http.HttpMessage
addConnection, addNoCache, addPragma, addProxyConnection, addTransferEncoding, addVia, checkNoStore, checkOnlyIfCached, delState, emit, emit, emitHeaders, endEmit, enumerateHeaderDescriptions, enumerateHeaderDescriptions, generateExtNamespace, getCacheControl, getCManExtHeader, getConnection, getCookie, getCOptExtHeader, getDate, getDeeperClone, getEmitDate, getExtensionHeaders, getExtHeader, getExtList, getHeaderValue, getHeaderValue, getHeaderValue, getHeaderValue, getHttpCManExtDecl, getHttpCOptExtDecl, getHttpManExtDecl, getHttpOptExtDecl, getMajorVersion, getManExtHeader, getMaxAge, getMinorVersion, getNoCache, getOptExtHeader, getPragma, getProtocol, getProtocolInfo, getProtocolQuery, getProtocolRequest, getProxyConnection, getSetCookie, getSMaxAge, getState, getStateNames, getTrailer, getTransferEncoding, getUpgrade, getValue, getValue, getVersion, getVia, hasConnection, hasHeader, hasHeader, hasPragma, hasProxyConnection, hasState, hasTransferEncoding, notifyHeader, registerExtHeader, registerHeader, registerHeader, removeHeader, removeHeader, setCacheControl, setConnection, setCookie, setDate, setEnd2EndExtensionAcknowledgmentHeader, setExtensionHeader, setHeaderValue, setHeaderValue, setHeaderValue, setHopByHopExtensionAcknowledgmentHeader, setHttpCManExtDecl, setHttpCOptExtDecl, setHttpExtDecl, setHttpManExtDecl, setHttpOptExtDecl, setMaxAge, setNamespaces, setNoCache, setNoCache, setNoStore, setOnlyIfCached, setPragma, setProtocol, setProtocolInfo, setProtocolQuery, setProtocolRequest, setProxyConnection, setSetCookie, setSMaxAge, setState, setTrailer, setTransferEncoding, setUpgrade, setValue, setVia
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THE_SERVER

public static java.net.URL THE_SERVER
The URL that means * for an OPTIONS method.


ORIG_URL_STATE

public static final java.lang.String ORIG_URL_STATE
the state of original URL

See Also:
Constant Field Values

client

protected Client client

parser

protected MimeParser parser

in

protected java.io.InputStream in

keepcon

protected boolean keepcon

internal

protected boolean internal

original

protected Request original

filters

protected ResourceFilter[] filters

infilters

protected int infilters
Constructor Detail

Request

public Request(Client client,
               MimeParser parser)
Method Detail

setState

public void setState(java.lang.String name,
                     java.lang.String state)
Description copied from interface: RequestInterface
FIXME doc

Specified by:
setState in interface RequestInterface

notifyEndParsing

public void notifyEndParsing(MimeParser parser)
                      throws HttpParserException,
                             java.io.IOException
Fix the target URL of the request, this is the only good time to do so.

Specified by:
notifyEndParsing in interface MimeHeaderHolder
Overrides:
notifyEndParsing in class HttpRequestMessage
Parameters:
parser - The MimeParser
Throws:
HttpParserException - if parsing failed.
java.io.IOException - if an IO error occurs.

canKeepConnection

public boolean canKeepConnection()

setTargetResource

protected void setTargetResource(ResourceReference resource)

getTargetResource

public ResourceReference getTargetResource()
Get this request target resource.

Returns:
An instance of HTTPResource, or null if not found.

setProxy

public void setProxy(boolean onoff)

isProxy

public boolean isProxy()

getURLPath

public java.lang.String getURLPath()
Description copied from interface: RequestInterface
Get the URL path of the target resource.

Specified by:
getURLPath in interface RequestInterface

setURLPath

public void setURLPath(java.lang.String path)

hasContentLength

public boolean hasContentLength()

hasContentType

public boolean hasContentType()

hasAccept

public boolean hasAccept()

hasAcceptCharset

public boolean hasAcceptCharset()

hasAcceptEncoding

public boolean hasAcceptEncoding()

hasAcceptLanguage

public boolean hasAcceptLanguage()

hasAuthorization

public boolean hasAuthorization()
Description copied from class: HttpRequestMessage
Does this request has some specific authorization infos.

Overrides:
hasAuthorization in class HttpRequestMessage
Returns:
A boolean.

hasProxyAuthorization

public boolean hasProxyAuthorization()

getQueryString

public java.lang.String getQueryString()

hasQueryString

public boolean hasQueryString()

isInternal

public boolean isInternal()
Description copied from interface: RequestInterface
Return true is the request is internal.

Specified by:
isInternal in interface RequestInterface
Returns:
a boolean.

setInternal

public void setInternal(boolean onoff)

getOriginal

public Request getOriginal()

setFilters

protected void setFilters(ResourceFilter[] filters,
                          int infilters)

getClone

public HttpMessage getClone()
Clone this request, in order to launch an internal request. This method can be used to run a request in some given context, defined by an original request. It will preserve all the original information (such as authentication, etc), and will provide a clone of the original request.

The original request and its clone differ in the following way:

To run an internal request, the caller can then use the org.w3c.jigsaw.http.httpd perform method.

Overrides:
getClone in class HttpMessage
Returns:
A fresh Request instance, marked as internal.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Get this reply entity body. The reply entity body is returned as an InputStream, that the caller has to read to actually get the bytes of the content.

Returns:
An InputStream instance. If the reply has no body, the returned input stream will just return -1 on first read.
Throws:
java.io.IOException

unescape

public static java.lang.String unescape(java.lang.String s)
Unescape a HTTP escaped string

Parameters:
s - The string to be unescaped
Returns:
the unescaped string.

makeBadRequestReply

public ReplyInterface makeBadRequestReply()
Description copied from interface: RequestInterface
Get a "Bad request" reply.

Specified by:
makeBadRequestReply in interface RequestInterface
Returns:
a ReplyInterface instance.

makeReply

public Reply makeReply(int status)
Make an empty Reply object matching this request version.

Parameters:
status - The status of the reply.

skipBody

public void skipBody()
skip the body


getClient

public Client getClient()
Get the client of this request.


setStream

public void setStream(java.io.InputStream is)
Set this reply entity body.

Parameters:
is - the InputStream instance. USE CAREFULLY : need to be thread-safe