|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol
org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorConnection
Field Summary | |
static java.lang.String |
DEFAULT_ENCODING
|
static java.lang.String |
FORM_POST_MIME_TYPE
Standard Mime type for POST-ed forms. |
Constructor Summary | |
EnhydraDirectorConnection()
|
Method Summary | |
void |
activate()
Override the activate() method to allow per-connection variables to be reset for each new connection. |
void |
addCookie(javax.servlet.http.Cookie cookie)
Add a cookie to the list of cookies to send to the browser. |
void |
addDateHeader(java.lang.String name,
long date)
Adds a response header with the given name and date value. |
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a response header with the given name and integer value. |
void |
addIntHeader(java.lang.String name,
int value)
Adds a response header with the given name and integer value. |
protected boolean |
authRequired()
Implementation class must provide this method. |
void |
closeInput()
Discards any further incoming request entity data and marks the input stream as "closed". |
void |
closeOutput()
Method to close output stream. |
boolean |
containsHeader(java.lang.String name)
Returns true if the current response contains the
named header. |
void |
doWrite(byte[] buffer,
int pos,
int count)
Write a chunk of bytes. |
java.lang.String |
encodeRedirectUrl(java.lang.String url)
Encodes the specified URL for use in the sendRedirect method. |
java.lang.String |
encodeRedirectURL(java.lang.String url)
|
java.lang.String |
encodeUrl(java.lang.String url)
Encodes the specified URL by including the session ID in it, or if encoding is not needed, returns the URL unchanged. |
java.lang.String |
encodeURL(java.lang.String url)
mora servlet response Sets the locale of the response. |
void |
flushBuffer()
Forces any content in the buffer to be written to the client. |
java.lang.String |
formatResponseCookie(javax.servlet.http.Cookie cookie)
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of an attribute of the request. |
java.util.Enumeration |
getAttributeNames()
|
protected byte[] |
getAuthData()
Abstract method to get authentication secret data. |
java.lang.String |
getAuthType()
Gets the authentication scheme of this request. |
int |
getBufferSize()
Returns the actual buffer size used for the response. |
java.lang.String |
getCharacterEncoding()
Returns the charset used for the body. |
int |
getContentLength()
Get the size of the request data. |
java.lang.String |
getContentType()
Get the content type of the request. |
javax.servlet.http.Cookie[] |
getCookies()
Gets the array of cookies found in this request. |
long |
getDateHeader(java.lang.String name)
Gets the value of the requested date header field of this request. |
boolean |
getEnableLookups()
|
protected EnhydraDirectorFunction |
getFunction(int type)
Internal dispatch table for server side function handlers. |
java.lang.String |
getHeader(java.lang.String name)
Gets the value of the requested header field of this request. |
java.util.Enumeration |
getHeaderNames()
Gets the header names for this request. |
java.util.Enumeration |
getHeaders(java.lang.String name)
Returns all the values of the specified requst header as an Enumeration of String objects.
|
java.lang.String |
getHost()
Get the host name |
java.net.InetAddress |
getInetAddress()
|
javax.servlet.ServletInputStream |
getInputStream()
Get an input stream for reading binary data in the request body. |
int |
getIntHeader(java.lang.String name)
Gets the value of the specified integer header field of this request. |
java.lang.String |
getIPPortToken()
|
java.lang.String |
getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the request was received. |
java.lang.String |
getLocalName()
Returns the host name of the Internet Protocol (IP) interface on which the request was received. |
int |
getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received. |
java.lang.String |
getMessage()
|
java.lang.String |
getMethod()
Gets the HTTP method (for example, GET, POST, PUT) with which this request was made. |
javax.servlet.ServletOutputStream |
getOutputStream()
Returns the byte output stream object for this response. |
java.lang.String |
getParameter(java.lang.String name)
Get a string containing the lone value of the specified parameter. |
java.util.Enumeration |
getParameterNames()
Get the parameter names for this request. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Get the values of the specified parameter for the request. |
java.lang.String |
getProtocol()
Get the protocol and version of the request. |
java.lang.String |
getQueryString()
Gets any query string that is part of the HTTP request URI. |
java.io.BufferedReader |
getReader()
Returns a buffered reader for reading text in the request body. |
java.lang.String |
getRemoteAddr()
Get the IP address of the agent that sent the request. |
java.lang.String |
getRemoteHost()
Get the fully qualified host name of the agent that sent the request. |
int |
getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request. |
java.lang.String |
getRemoteUser()
Gets the name of the user making this request. |
java.lang.String |
getRequestURI()
Get the part of this request's URI that is to the left of any query string. |
java.lang.StringBuffer |
getRequestURL()
Reconstructs the URL the client used to make the request. |
int |
getResponseContentLength()
Return the Content Length associated with this Response. |
java.lang.String |
getResponseContentType()
Return the Content Type associated with this Response. |
javax.servlet.http.Cookie[] |
getResponseCookies()
Get the Cookies associated with this Response.. |
long |
getResponseDateHeader(java.lang.String name)
|
java.lang.String |
getResponseHeader(java.lang.String name)
Get the Header with the specified name associated with this Response. |
java.util.Enumeration |
getResponseHeaderNames()
Return the Header Names associated with this Response. |
java.util.Enumeration |
getResponseHeaders(java.lang.String name)
|
int |
getResponseIntHeader(java.lang.String name)
|
java.lang.String |
getScheme()
Get the scheme of the URL used in this request, for example "http", "https", or "ftp". |
java.lang.String |
getServerName()
Get the host name of the server that received the request. |
int |
getServerPort()
Get the port number on which this request was received. |
boolean |
getSessionAffinity()
|
boolean |
getSessionAffinityIdChangeRequest()
|
int |
getStatus()
Return the Status Type associated with this Response. |
java.io.PrintWriter |
getWriter()
Gets a character stream printing writer for the response. |
boolean |
isCommitted()
Returns a boolean indicating whether the response has been committed. |
boolean |
isSecure()
|
java.lang.String |
maxAgeToExpires(int maxAge)
|
java.util.Hashtable |
mergeParameters(java.util.Hashtable one,
java.util.Hashtable two)
|
java.util.Hashtable |
parsePostData(int len,
javax.servlet.ServletInputStream in,
java.lang.String encoding)
|
protected void |
processCgiHeader(byte[] nameBytes,
byte[] valueBytes)
Abstract method to get authentication secret data. |
protected void |
processCookie(byte[] nameBytes,
byte[] valueBytes)
Abstract method to get authentication secret data. |
protected void |
processHttpHeader(byte[] nameBytes,
byte[] valueBytes)
Abstract method to get authentication secret data. |
void |
recycle()
|
void |
removeAttribute(java.lang.String name)
Remove attribute with the specified name |
void |
reset()
Clears any data that exists in the buffer as well as the status code and headers. |
void |
resetBuffer()
|
void |
sendError(int sc)
Sends an error response to the client using the specified status code and a default message. |
void |
sendError(int sc,
java.lang.String msg)
Sends an error response to the client using the specified status code and descriptive message. |
void |
sendRedirect(java.lang.String location)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Set the Attribute with the specified name and value |
void |
setAuthData(java.lang.String authData)
Sets authentication data. |
void |
setBufferSize(int size)
Sets the preferred buffer size for the body of the response. |
void |
setCharacterEncoding(java.lang.String e)
|
void |
setContentLength(int len)
Sets the value of the outgoing Content-Length header.
|
void |
setContentType(java.lang.String type)
Sets the MIME content type of the outgoing response. |
void |
setDateHeader(java.lang.String name,
long date)
Sets a response header with the given name and date value. |
void |
setEnableLookups(boolean enable)
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets a response header with the given name and integer value. |
void |
setIntHeader(java.lang.String name,
int value)
Sets a response header with the given name and integer value. |
void |
setIPPortToken(java.lang.String ipPortToken)
These values are used by the session manager to determine what IP and Port number to include with the user's session cookie. |
void |
setQueryString(java.lang.String queryString)
Sets the query string that is part of the HTTP request URI. |
void |
setSessionAffinity(boolean sessionAffinity)
This flag is used by the session manager to determine if the IP and Port string should be included in the session cookie. |
void |
setSessionAffinityIdChangeRequest(boolean newValue)
If EnhydraDirector request to change ServerID this will be set to "true" |
void |
setStatus(int sc)
Sets the status code for this response. |
void |
setStatus(int sc,
java.lang.String sm)
Sets the status code for this response. |
void |
setURIEncoding(java.lang.String URIEncoding)
|
void |
setUseBodyEncodingForURI(boolean useBodyEncodingForURI)
|
protected void |
stuffInternalHeader(java.lang.String name,
java.lang.String value)
Private helper method to stuff a header into the request headers list. |
Methods inherited from class org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol |
authenticate, authenticate, callback, closeConnection, connect, deactivate, discardEntity, finishHeaders, getStateName, getStateName, inputAvailable, isAuthenticated, isConnected, isOpen, read, read, read, readExactly, readExactly, sendCookie, sendHeader, skip, toString, write, write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String DEFAULT_ENCODING
public static final java.lang.String FORM_POST_MIME_TYPE
Constructor Detail |
public EnhydraDirectorConnection() throws java.io.IOException
Method Detail |
public void setUseBodyEncodingForURI(boolean useBodyEncodingForURI)
public void setURIEncoding(java.lang.String URIEncoding)
public boolean getEnableLookups()
public void setEnableLookups(boolean enable)
public javax.servlet.http.Cookie[] getResponseCookies()
public void setIPPortToken(java.lang.String ipPortToken)
public java.lang.String getIPPortToken()
public void setSessionAffinity(boolean sessionAffinity)
public boolean getSessionAffinity()
public void activate() throws java.io.IOException
activate
in class EnhydraDirectorProtocol
java.io.IOException
- If an error occurs.public void recycle()
protected EnhydraDirectorFunction getFunction(int type)
getFunction
in class EnhydraDirectorProtocol
type
- Protocol-defined function type number.
protected boolean authRequired()
authRequired
in class EnhydraDirectorProtocol
true
if authentication is required.protected byte[] getAuthData()
This method must be provided by the implementation class. It checks the configuration and finds the secret authentication data used to verify authentication responses from clients.
getAuthData
in class EnhydraDirectorProtocol
null
if authentication data does not exist.public void setAuthData(java.lang.String authData)
This method allows the connection method handler to pass the configured authentication string to this instance for use in establishing connections.
protected void processCgiHeader(byte[] nameBytes, byte[] valueBytes)
processCgiHeader
in class EnhydraDirectorProtocol
null
if authentication data does not exist.protected void stuffInternalHeader(java.lang.String name, java.lang.String value)
If this is used to stuff 'pseudo' headers for internal code, then the headers should have illegal names that can't conflict with valid HTTP headers.
name
- The header name.
null
if authentication data does not exist.protected void processHttpHeader(byte[] nameBytes, byte[] valueBytes)
processHttpHeader
in class EnhydraDirectorProtocol
null
if authentication data does not exist.protected void processCookie(byte[] nameBytes, byte[] valueBytes)
processCookie
in class EnhydraDirectorProtocol
null
if authentication data does not exist.public java.lang.String getAuthType()
public javax.servlet.http.Cookie[] getCookies()
public long getDateHeader(java.lang.String name)
name
- the String containing the name of the requested
header field. The comparison is case insensitive.
java.lang.IllegalArgumentException
- If value of header can't be
converted to an int.public java.lang.String getHeader(java.lang.String name)
name
- The String containing the name of the requested
header field. The comparison is case insensitive.
public java.util.Enumeration getHeaderNames()
public java.util.Enumeration getHeaders(java.lang.String name)
Enumeration
of String
objects.
Some headers, such as Accept-Language
can be sent
by clients as several headers each with a different value rather
than sending the header as a comma separated list.
If the request did not include any headers of the specified name,
this method returns an empty Enumeration
. The
header name is case insensitive. You can use this method with
any request header.
name
- A String
specifying the header name.
Enumeration
containing the values of the
requested header, or an empty Enumeration
if the request does not have any headers of that name.public int getIntHeader(java.lang.String name) throws java.lang.NumberFormatException
name
- The String containing the name of the requested
header field. The comparison is case insensitive.
java.lang.NumberFormatException
- If value of header can't be
converted to an int.public java.lang.String getMethod()
public java.lang.String getQueryString()
public void setQueryString(java.lang.String queryString)
public java.lang.String getRemoteUser()
public int getLocalPort()
public int getRemotePort()
public java.lang.String getLocalAddr()
public java.lang.String getLocalName()
public java.lang.String getRequestURI()
HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)
public java.lang.Object getAttribute(java.lang.String name)
name
- The name of the attribute whose value is required.
public java.util.Enumeration getAttributeNames()
public int getContentLength()
public java.lang.String getContentType()
public javax.servlet.ServletInputStream getInputStream() throws java.io.IOException
java.lang.IllegalStateException
- if getReader has been
called on this same request.
java.io.IOException
- on other I/O related errors.getReader
public java.lang.String getParameter(java.lang.String name)
This call is case sensitive.
name
- The name of the parameter whose value is required.
getParameterValues(java.lang.String)
public java.util.Enumeration getParameterNames()
public java.lang.String[] getParameterValues(java.lang.String name)
The name is case sensitive.
name
- the name of the parameter whose value is required.
ServletRequest.getParameter(java.lang.String)
public java.lang.String getProtocol()
<protocol>/<major version>.<minor
version>
.public java.io.BufferedReader getReader() throws java.io.IOException
UnsupportedEncodingException
- if the character set encoding
is unsupported, so the text can't be correctly decoded.
java.lang.IllegalStateException
- if getInputStream has been
called on this same request.
java.io.IOException
- on other I/O related errors.getInputStream
public java.lang.String getRemoteAddr()
public java.net.InetAddress getInetAddress()
public java.lang.String getRemoteHost()
public java.lang.String getScheme()
public java.lang.String getServerName()
public java.lang.String getHost()
public int getServerPort()
public boolean isSecure()
public void removeAttribute(java.lang.String name)
public void setHeader(java.lang.String name, java.lang.String value)
If the header has already been set, the new value overwrites the
previous one. The containsHeader
method can be used
to test for the presence of a header before setting its value.
name
- The name of the header.value
- The value to assign.public void addHeader(java.lang.String name, java.lang.String value)
This method allows response headers to have multiple values.
name
- The name of the header.value
- The value to assign.public void addCookie(javax.servlet.http.Cookie cookie)
cookie
- The cookie to add.public boolean containsHeader(java.lang.String name)
true
if the current response contains the
named header.
name
- The name of the header.
public java.lang.String encodeUrl(java.lang.String url)
public java.lang.String encodeRedirectUrl(java.lang.String url)
sendRedirect
method.
public java.lang.String getMessage()
public void sendError(int sc, java.lang.String msg) throws java.io.IOException
sc
- The status code.msg
- The descriptive message.
java.io.IOException
- If an I/O error has occured.public void sendError(int sc) throws java.io.IOException
sc
- The status code.
java.io.IOException
- If an I/O error has occured.public void sendRedirect(java.lang.String location) throws java.io.IOException
location
- The redirect location URL.
java.io.IOException
- If an I/O error has occured.public void setDateHeader(java.lang.String name, long date)
If the header has already been set, the new value overwrites the
previous one. The containsHeader
method can be used
to test for the presence of a header before setting its value.
name
- The name of the header.public void addDateHeader(java.lang.String name, long date)
This method allows response headers to have multiple values.
name
- The name of the header.public void setIntHeader(java.lang.String name, int value)
If the header has already been set, the new value overwrites the
previous one. The containsHeader
method can be used
to test for the presence of a header before setting its value.
name
- The name of the header.value
- The value to assign.public void addIntHeader(java.lang.String name, int value)
This method allows response headers to have multiple values.
name
- The name of the header.value
- The value to assign.public void setStatus(int sc, java.lang.String sm)
sc
- The HTTP status code.sm
- Message to send with status code.public void setStatus(int sc)
This method is used to set the return status code when there
is no error. (For example, SC_OK or SC_MOVED_TEMPORARILY). If there
is an error, the sendError
method should be used instead.
sc
- The status code.public java.lang.String getCharacterEncoding()
public javax.servlet.ServletOutputStream getOutputStream() throws java.io.IOException
This method may not be called if it or getWriter()
have already been called.
java.lang.IllegalStateException
- If this method is called after the
output stream has already been gotten.
java.io.IOException
public java.io.PrintWriter getWriter() throws java.io.IOException
This implementation is not fully functional, since it uses the default character encoding instead of mapping the charset portion of the Content-Type to the correct encoding.
PrintWriter
stream for output.
java.io.IOException
- If an I/O error occurs.
java.lang.IllegalStateException
- If getOutputStream() already called.
UnsupportedEncodingException
- If an unknown character
encoding is specified.public void setContentLength(int len)
Content-Length
header.
Sets the length of the outgoing content. Any data sent beyond this length will be discarded, and the output will be padded to this length after the output stream is closed. Padding is with octets of value 0 (zero).
len
- The Content-Length value.public void setContentType(java.lang.String type)
FIXME XXX - This is not fully implemented. It simply copies
the type verbatim to the MIME headers sent with the response.
Future versions of this class may attempt to read the
"charset" portion of the content type to determine which
encoding, if any, should be used for streams returned by
getWriter()
. This will require a configuration
table that maps locales, MIME charsets, and Java encodings.
type
- The MIME type of this response.public void setBufferSize(int size)
The servlet container will use a buffer at least as large as
the size requested. The actual buffer size used can be found
using getBufferSize
.
A larger buffer allows more content to be written before anything is actually sent, this providing the servlet with more time to set appropriate status codes and headers. A smaller buffer decreases server memory load and allows the client to start receiving data more quickly.
This method must be called before any response body content is
written; if content has been written, this method throws
an IllegalStateException
.
size
- The preferred buffer size.
java.lang.IllegalStateException
- If called after content written.public int getBufferSize()
If no buffering is used, this method returns 0
.
public boolean isCommitted()
A committed response has already had its status code and headers written.
public void reset() throws java.lang.IllegalStateException
IllegalStateException
.
java.lang.IllegalStateException
- If the response has already
been committed.public java.lang.String encodeURL(java.lang.String url)
This is supposed to set the headers, including Content-Type
and Content-Encoding
. However, it is not * clear how to
map between character encodings and locales.
Probably, future revisions of this class will use some sort of mapping
table to set the encodings. For now, it just keeps track of which
locale is set and uses Latin1 encoding in the underlying output
stream. Servlets that want to use other encodings should create an
appropriate PrintWriter
on the binary stream given by
getOutputStream
.
XXX - FIXME.
public void setAttribute(java.lang.String name, java.lang.Object value)
public java.lang.String encodeRedirectURL(java.lang.String url)
public void resetBuffer()
public void setCharacterEncoding(java.lang.String e)
public java.lang.String getResponseHeader(java.lang.String name)
public java.util.Enumeration getResponseHeaderNames()
public int getResponseIntHeader(java.lang.String name)
public long getResponseDateHeader(java.lang.String name)
public java.util.Enumeration getResponseHeaders(java.lang.String name)
public int getStatus()
public java.lang.String getResponseContentType()
public int getResponseContentLength()
public java.lang.StringBuffer getRequestURL()
Because this method returns a StringBuffer
,
not a string, you can modify the URL easily, for example,
to append query parameters.
This method is useful for creating redirect messages and for reporting errors.
StringBuffer
object containing
the reconstructed URLpublic java.util.Hashtable mergeParameters(java.util.Hashtable one, java.util.Hashtable two)
public void doWrite(byte[] buffer, int pos, int count) throws java.io.IOException
java.io.IOException
public void closeOutput() throws java.io.IOException
EnhydraDirectorProtocol
closeOutput
in class EnhydraDirectorProtocol
java.io.IOException
public void closeInput() throws java.io.IOException
EnhydraDirectorProtocol
closeInput
in class EnhydraDirectorProtocol
java.io.IOException
- if an error occurs while discarding
entity data. This usually will cause the
protocol to go out of sync.public void flushBuffer() throws java.io.IOException
A call to this method automatically commits the response, meaning the status code and headers will be written.
java.io.IOException
- If an I/O error occurs.public void setSessionAffinityIdChangeRequest(boolean newValue)
newValue
- The sessionAffinityIdChangeRequest to set.public boolean getSessionAffinityIdChangeRequest()
public java.lang.String formatResponseCookie(javax.servlet.http.Cookie cookie)
public java.lang.String maxAgeToExpires(int maxAge)
public java.util.Hashtable parsePostData(int len, javax.servlet.ServletInputStream in, java.lang.String encoding)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |