org.w3c.www.http
Class HttpReplyMessage

java.lang.Object
  extended by org.w3c.www.http.HttpMessage
      extended by org.w3c.www.http.HttpEntityMessage
          extended by org.w3c.www.http.HttpReplyMessage
All Implemented Interfaces:
java.lang.Cloneable, HTTP, MimeHeaderHolder
Direct Known Subclasses:
Reply, Reply

public class HttpReplyMessage
extends HttpEntityMessage


Field Summary
static int H_ACCEPT_RANGES
           
static int H_AGE
           
static int H_AUTHENTICATION_INFO
           
static int H_LOCATION
           
static int H_PROXY_AUTHENTICATE
           
static int H_PUBLIC
           
static int H_RETRY_AFTER
           
static int H_SERVER
           
static int H_VARY
           
static int H_WARNING
           
static int H_WWW_AUTHENTICATE
           
protected  java.lang.String reason
          The reason phrase.
protected  int status
          The status associated with this reply.
 
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
HttpReplyMessage()
           
HttpReplyMessage(MimeParser parser)
           
 
Method Summary
 void addAuthenticationInfo(java.lang.String name, java.lang.String value)
          Add the given parameter/value pair to the Authentication Info header
 void addWarning(HttpWarning warning)
          Add a warning to this reply message.
 boolean checkMustRevalidate()
          Check the must-revalidate directive of the cache control header.
 boolean checkProxyRevalidate()
          Check the proxy-revalidate directive of the cache control header.
 boolean checkPublic()
          Check the public directive of the cache control header.
 void dump(java.io.OutputStream out)
           
 java.lang.String[] getAcceptRanges()
          Get the list of accepted ranges.
 int getAge()
          Get the age of the attached entity.
 HttpParamList getAuthenticationInfo()
          Get the Authentication Info (see digest auth) attached to this reply.
 java.lang.String getLocation()
          Get the location of the reply.
 java.lang.String[] getPrivate()
          Get the private directive of the cache control header.
 HttpChallenge getProxyAuthenticate()
          Get the proxy authentication challenge from this reply.
 java.lang.String[] getPublic()
          Get the list of publicly allowed methods on queried resource.
 java.lang.String getReason()
          Get the reason phrase for this reply.
 java.lang.String getServer()
          Get the description of the server that generated this reply.
 java.lang.String getStandardReason(int status)
          Get the standard HTTP reason phrase for the given status code.
 int getStatus()
          Get this reply status code.
 java.lang.String[] getVary()
          Get the vary header value.
 HttpWarning[] getWarning()
          Get the list of warnings attached to this reply.
 HttpChallenge getWWWAuthenticate()
          Get the challenge attached to this reply.
 boolean notifyBeginParsing(MimeParser parser)
          MimeHeaderHolder implementation - Begining of reply parsing.
 void setAcceptRanges(java.lang.String[] units)
          Set the list of units in which range requests are accepted.
 void setAge(int age)
          Set the age of the attached entity.
 void setAuthenticationInfo(HttpParamList plist)
          Attach Authentication Info to this reply.
 void setLocation(java.lang.String location)
          Set the location value of the reply.
 void setLocation(java.net.URL location)
          Set the location value of the reply.
 void setMustRevalidate(boolean onoff)
          Set the must-revalidate cache control directive.
 void setProxyAuthenticate(HttpChallenge challenge)
          Set thye proxy authentication challenge on this reply.
 void setProxyRevalidate(boolean onoff)
          Set the proxy-revalidate cache control directive.
 void setPublic(boolean onoff)
          Set the public cache control directive.
 void setPublic(java.lang.String[] mth)
          Set the list of allowed method on queried resource.
 void setReason(java.lang.String reason)
          Set the reason phrase of this reply.
 void setRetryAfter(int delay)
          set the retry after as a delay
 void setRetryAfter(long date)
          set the retry after as a date
 void setServer(java.lang.String server)
          Set the description of the server.
 void setStatus(int status)
          Set this reply status code.
 void setVary(java.lang.String[] varies)
          Set the vary header value.
 void setWarning(HttpWarning[] warnings)
          Set the warning list attached to this reply.
 void setWWWAuthenticate(HttpChallenge challenge)
          Attach a challenge to this reply.
protected  void startEmit(java.io.OutputStream out, int what)
          Emit the status line before emiting the actual reply headers.
 
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, getClone, 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, notifyEndParsing, 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

H_ACCEPT_RANGES

public static int H_ACCEPT_RANGES

H_AGE

public static int H_AGE

H_LOCATION

public static int H_LOCATION

H_PROXY_AUTHENTICATE

public static int H_PROXY_AUTHENTICATE

H_PUBLIC

public static int H_PUBLIC

H_RETRY_AFTER

public static int H_RETRY_AFTER

H_SERVER

public static int H_SERVER

H_VARY

public static int H_VARY

H_WARNING

public static int H_WARNING

H_WWW_AUTHENTICATE

public static int H_WWW_AUTHENTICATE

H_AUTHENTICATION_INFO

public static int H_AUTHENTICATION_INFO

status

protected int status
The status associated with this reply.


reason

protected java.lang.String reason
The reason phrase.

Constructor Detail

HttpReplyMessage

public HttpReplyMessage(MimeParser parser)

HttpReplyMessage

public HttpReplyMessage()
Method Detail

startEmit

protected void startEmit(java.io.OutputStream out,
                         int what)
                  throws java.io.IOException
Emit the status line before emiting the actual reply headers.

Overrides:
startEmit in class HttpMessage
Parameters:
out - The output stream to emit the reply to.
Throws:
java.io.IOException - if an IO error occurs.

dump

public void dump(java.io.OutputStream out)
Overrides:
dump in class HttpMessage

notifyBeginParsing

public boolean notifyBeginParsing(MimeParser parser)
                           throws HttpParserException,
                                  java.io.IOException
MimeHeaderHolder implementation - Begining of reply parsing. If we can determine that this reply version number is less then 1.0, then we skip the header parsing by returning true to the MIME parser.

Otherwise, we parse the status line, and return false to make the MIME parser continue.

Specified by:
notifyBeginParsing in interface MimeHeaderHolder
Overrides:
notifyBeginParsing in class HttpMessage
Parameters:
parser - The Mime parser.
Returns:
A boolean true if the MIME parser should stop parsing, false otherwise.
Throws:
java.io.IOException - If some IO error occured while reading the stream.
HttpParserException - if parsing failed.

getStandardReason

public java.lang.String getStandardReason(int status)
Get the standard HTTP reason phrase for the given status code.

Parameters:
status - The given status code.
Returns:
A String giving the standard reason phrase, or null if the status doesn't match any knowned error.

getStatus

public int getStatus()
Get this reply status code.

Returns:
An integer, giving the reply status code.

setStatus

public void setStatus(int status)
Set this reply status code. This will also set the reply reason, to the default HTTP/1.1 reason phrase.

Parameters:
status - The status code for this reply.

getReason

public java.lang.String getReason()
Get the reason phrase for this reply.

Returns:
A String encoded reason phrase.

setReason

public void setReason(java.lang.String reason)
Set the reason phrase of this reply.

Parameters:
reason - The reason phrase for this reply.

getPrivate

public java.lang.String[] getPrivate()
Get the private directive of the cache control header.

Returns:
A list of fields (potentially empty) encoded as an array of String (with 0 length if empty), or null if undefined.

checkPublic

public boolean checkPublic()
Check the public directive of the cache control header.

Returns:
A boolean true if set, false otherwise.

setPublic

public void setPublic(boolean onoff)
Set the public cache control directive.

Parameters:
onoff - Set it on or off.

checkProxyRevalidate

public boolean checkProxyRevalidate()
Check the proxy-revalidate directive of the cache control header.

Returns:
A boolean true if set, false otherwise.

setProxyRevalidate

public void setProxyRevalidate(boolean onoff)
Set the proxy-revalidate cache control directive.

Parameters:
onoff - Set it on or off.

checkMustRevalidate

public boolean checkMustRevalidate()
Check the must-revalidate directive of the cache control header.

Returns:
A boolean true if set, false otherwise.

setMustRevalidate

public void setMustRevalidate(boolean onoff)
Set the must-revalidate cache control directive.

Parameters:
onoff - Set it on or off.

getAcceptRanges

public java.lang.String[] getAcceptRanges()
Get the list of accepted ranges.

Returns:
The list of units in which range requests are accepted, encoded as an array of String, or null if undefined.

setAcceptRanges

public void setAcceptRanges(java.lang.String[] units)
Set the list of units in which range requests are accepted.

Parameters:
units - The list of units, encoded as a String array, or null to reset the value.

getAge

public int getAge()
Get the age of the attached entity.

Returns:
An integer giving the age as a number of seconds, or -1 if undefined.

setAge

public void setAge(int age)
Set the age of the attached entity.

Parameters:
age - The age of the attached entity as a number of seconds, or null to reset the value.

getLocation

public java.lang.String getLocation()
Get the location of the reply. The location header field keeps track of where to relocate clients if needed.

Returns:
The location encoded as a String.

setLocation

public void setLocation(java.net.URL location)
Set the location value of the reply.

Parameters:
location - The location an URL instance, or null to reset the value.

setLocation

public void setLocation(java.lang.String location)
Set the location value of the reply.

Parameters:
location - The location a String, or null to reset the value.

getProxyAuthenticate

public HttpChallenge getProxyAuthenticate()
Get the proxy authentication challenge from this reply.

Returns:
An instance of HttpChallenge, or null if undefined.

setProxyAuthenticate

public void setProxyAuthenticate(HttpChallenge challenge)
Set thye proxy authentication challenge on this reply.

Parameters:
challenge - The challenge to set, or null to reset the value.

getPublic

public java.lang.String[] getPublic()
Get the list of publicly allowed methods on queried resource.

Returns:
The list of methods, encoded as a String array, or null if undefined.

setPublic

public void setPublic(java.lang.String[] mth)
Set the list of allowed method on queried resource.

Parameters:
mth - The list of public methods, encoded as a String array, or null to reset the value.

getServer

public java.lang.String getServer()
Get the description of the server that generated this reply.

Returns:
A String giving the description, or null if undefined.

setServer

public void setServer(java.lang.String server)
Set the description of the server.

Parameters:
server - The String decribing the server, or null to reset the value.

setRetryAfter

public void setRetryAfter(int delay)
set the retry after as a delay

Parameters:
an - integer representing the delay, in seconds

setRetryAfter

public void setRetryAfter(long date)
set the retry after as a date

Parameters:
long - the date as a long

getVary

public java.lang.String[] getVary()
Get the vary header value.

Returns:
A list of field-names on which the negotiated resource vary, or a list containing only * (if varies on all headers), or null if undefined.

setVary

public void setVary(java.lang.String[] varies)
Set the vary header value.

Parameters:
varies - The list of headers on which this resource varies, or null to reset the value.

getWarning

public HttpWarning[] getWarning()
Get the list of warnings attached to this reply.

Returns:
An array of HttpWarning, or null if undefined.

setWarning

public void setWarning(HttpWarning[] warnings)
Set the warning list attached to this reply.

Parameters:
warnings - An array of warnings to attach to the given reply, or null to reset the value.

addWarning

public void addWarning(HttpWarning warning)
Add a warning to this reply message.

Parameters:
warning - The warning to add.

getWWWAuthenticate

public HttpChallenge getWWWAuthenticate()
Get the challenge attached to this reply.

Returns:
An instance of HttpChallenge, or null if undefined.

setWWWAuthenticate

public void setWWWAuthenticate(HttpChallenge challenge)
Attach a challenge to this reply.

Parameters:
challenge - The challenge to be attached to the reply, or null to reset the value.

getAuthenticationInfo

public HttpParamList getAuthenticationInfo()
Get the Authentication Info (see digest auth) attached to this reply.

Returns:
An instance of HttpParamList, or null if undefined.

setAuthenticationInfo

public void setAuthenticationInfo(HttpParamList plist)
Attach Authentication Info to this reply.

Parameters:
plist, - the parameter list to be attached to the reply, or null to reset the value.

addAuthenticationInfo

public void addAuthenticationInfo(java.lang.String name,
                                  java.lang.String value)
Add the given parameter/value pair to the Authentication Info header

Parameters:
String - the name of the value
String - the value