com.caucho.server.http
Class RunnerRequest

java.lang.Object
  |
  +--com.caucho.server.http.AbstractRequest
        |
        +--com.caucho.server.http.Request
              |
              +--com.caucho.server.http.RunnerRequest
All Implemented Interfaces:
CauchoRequest, HttpServletRequest, SecurityContextProvider, com.caucho.server.ServerRequest, ServletRequest

public class RunnerRequest
extends Request

Handles requests from a remote dispatcher. For example, mod_caucho and the IIS plugin use this protocol to talk to the backend.

Packets are straightforward:

code l2 l1 l0 contents
Where code is the code of the packet and l2-0 give 12 bits of length.

The protocol is designed to allow pipelining and buffering whenever possible. So most commands are not acked. Data from the frontend (POST) does need acks to prevent deadlocks at either end while waiting for new data.

The overriding protocol is controlled by requests from the frontend server.

A ping request:

 Frontend       Backend
 CSE_PING
 CSE_END
                CSE_END
 
 
 

A GET request:

 Frontend       Backend
 CSE_METHOD
 ...
 CSE_HEADER/CSE_VALUE
 CSE_END
                CSE_DATA
                CSE_DATA
                CSE_END
 
 
 

Short POST:

 Frontend       Backend
 CSE_METHOD
 ...
 CSE_HEADER/CSE_VALUE
 CSE_DATA
 CSE_END
                CSE_DATA
                CSE_DATA
                CSE_END
 
 
 

Long POST:

 Frontend       Backend
 CSE_METHOD
 ...
 CSE_HEADER/CSE_VALUE
 CSE_DATA
                CSE_DATA (optional)
 CSE_DATA
                CSE_ACK
                CSE_DATA (optional)
 CSE_DATA
                CSE_ACK
 CSE_END
                CSE_DATA
                CSE_END
 


Field Summary
static int CSE_ACK
           
static int CSE_AUTH_TYPE
           
static int CSE_CLIENT_CERT
           
static int CSE_CLOSE
           
static int CSE_CONTENT_LENGTH
           
static int CSE_CONTENT_TYPE
           
static int CSE_DATA
           
static int CSE_DUMP_SESSION
           
static int CSE_END
           
static int CSE_FLUSH
           
static int CSE_HEADER
           
static int CSE_IS_SECURE
           
static int CSE_KEEPALIVE
           
static int CSE_KILL_SESSION
           
static int CSE_LOAD_SESSION
           
static int CSE_METHOD
           
static int CSE_NULL
           
static int CSE_PATH_INFO
           
static int CSE_PING
           
static int CSE_PROTOCOL
           
static int CSE_QUERY
           
static int CSE_QUERY_STRING
           
static int CSE_REAL_PATH
           
static int CSE_REMOTE_ADDR
           
static int CSE_REMOTE_HOST
           
static int CSE_REMOTE_PORT
           
static int CSE_REMOTE_USER
           
static int CSE_SAVE_SESSION
           
static int CSE_SCRIPT_FILENAME
           
static int CSE_SEND_HEADER
           
static int CSE_SERVER_NAME
           
static int CSE_SERVER_PORT
           
static int CSE_SERVER_TYPE
           
static int CSE_SESSION_DATA
           
static int CSE_SESSION_GROUP
           
static int CSE_SESSION_SRUN
           
static int CSE_STATUS
           
static int CSE_URI
           
static int CSE_VALUE
           
 
Fields inherited from class com.caucho.server.http.Request
bogusSecure, cb, closeOnExit, conn, currentTransaction, filterStream, hasInputStream, invocationKey, isSecure, rawStream, response, server, sessionGroup, version
 
Fields inherited from class com.caucho.server.http.AbstractRequest
cache, calendar, CONTEXT_PATH, ERROR_URI, EXCEPTION, invocation, JSP_EXCEPTION, MESSAGE, PATH_INFO, QUERY_STRING, REQUEST_URI, SERVLET_PATH, STATUS_CODE
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Method Summary
 CharSegment getHeaderBuffer(char[] buf, int length)
           
 CharSegment getHeaderBuffer(java.lang.String key)
           
 void getHeaderBuffers(java.util.ArrayList values, java.lang.String key)
           
 java.util.Enumeration getHeaderNames()
          Enumerates the header keys
 CharSegment getMethodBuffer()
           
 CharSegment getProtocolBuffer()
           
 java.lang.String getRemoteAddr()
          Returns the Internet Protocol (IP) address of the client that sent the request.
 void getRemoteAddr(CharBuffer cb)
           
 java.lang.String getRemoteHost()
          Returns the fully qualified name of the client that sent the request, or the IP address of the client if the name cannot be determined.
 java.lang.String getRequestURI()
          Returns the URI for the request, special casing the IIS issues.
 java.lang.String getScheme()
          Returns the name of the scheme used to make this request, for example, http, https, or ftp.
 java.lang.String getServerName()
          Returns the host name of the server that received the request.
 int getServerPort()
          Returns the port number on which this request was received.
 byte[] getUriBuffer()
           
 int getUriLength()
           
 void handleConnection(com.caucho.server.Connection conn)
          Handle a connection.
 void setHeader(java.lang.String key, java.lang.String value)
           
protected  void start(ReadStream s)
          Clears variables at the start of a new request.
 
Methods inherited from class com.caucho.server.http.Request
findSessionIdFromConnection, finish, finishSession, getApplication, getAttribute, getAttributeNames, getChain, getCharacterEncoding, getContentLength, getContentType, getContextPath, getCookie, getCookies, getDate, getHeader, getHeaders, getInputStream, getLocale, getLocales, getMethod, getPageContextPath, getPagePathInfo, getPageQueryString, getPageServletPath, getPageURI, getParameter, getParameterMap, getParameterNames, getParameterValues, getPathInfo, getPathTranslated, getProtocol, getQueryString, getReader, getRealPath, getRequestApplication, getRequestDepth, getRequestedSessionId, getServletPath, getSession, getSessionGroup, getStream, getThreadRequest, init, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isSecure, isTesting, printRemoteAddr, removeAttribute, setAttribute, setCharacterEncoding, setVaryCookie
 
Methods inherited from class com.caucho.server.http.AbstractRequest
authenticate, createSession, getAuthType, getCauchoApplication, getDateHeader, getIntHeader, getMedia, getRemoteUser, getRemoteUser, getRequestDepth, getRequestDispatcher, getRequestURL, getSession, getUserPrincipal, isUserInRole, logoutUserPrincipal, setHasCookie
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CSE_NULL

public static final int CSE_NULL

CSE_PATH_INFO

public static final int CSE_PATH_INFO

CSE_PROTOCOL

public static final int CSE_PROTOCOL

CSE_METHOD

public static final int CSE_METHOD

CSE_QUERY_STRING

public static final int CSE_QUERY_STRING

CSE_SERVER_NAME

public static final int CSE_SERVER_NAME

CSE_SERVER_PORT

public static final int CSE_SERVER_PORT

CSE_REMOTE_HOST

public static final int CSE_REMOTE_HOST

CSE_REMOTE_ADDR

public static final int CSE_REMOTE_ADDR

CSE_REMOTE_PORT

public static final int CSE_REMOTE_PORT

CSE_REAL_PATH

public static final int CSE_REAL_PATH

CSE_SCRIPT_FILENAME

public static final int CSE_SCRIPT_FILENAME

CSE_REMOTE_USER

public static final int CSE_REMOTE_USER

CSE_AUTH_TYPE

public static final int CSE_AUTH_TYPE

CSE_URI

public static final int CSE_URI

CSE_CONTENT_LENGTH

public static final int CSE_CONTENT_LENGTH

CSE_CONTENT_TYPE

public static final int CSE_CONTENT_TYPE

CSE_IS_SECURE

public static final int CSE_IS_SECURE

CSE_SESSION_GROUP

public static final int CSE_SESSION_GROUP

CSE_CLIENT_CERT

public static final int CSE_CLIENT_CERT

CSE_SERVER_TYPE

public static final int CSE_SERVER_TYPE

CSE_STATUS

public static final int CSE_STATUS

CSE_SEND_HEADER

public static final int CSE_SEND_HEADER

CSE_HEADER

public static final int CSE_HEADER

CSE_VALUE

public static final int CSE_VALUE

CSE_DATA

public static final int CSE_DATA

CSE_FLUSH

public static final int CSE_FLUSH

CSE_KEEPALIVE

public static final int CSE_KEEPALIVE

CSE_ACK

public static final int CSE_ACK

CSE_END

public static final int CSE_END

CSE_CLOSE

public static final int CSE_CLOSE

CSE_QUERY

public static final int CSE_QUERY

CSE_PING

public static final int CSE_PING

CSE_SAVE_SESSION

public static final int CSE_SAVE_SESSION

CSE_LOAD_SESSION

public static final int CSE_LOAD_SESSION

CSE_SESSION_DATA

public static final int CSE_SESSION_DATA

CSE_KILL_SESSION

public static final int CSE_KILL_SESSION

CSE_SESSION_SRUN

public static final int CSE_SESSION_SRUN

CSE_DUMP_SESSION

public static final int CSE_DUMP_SESSION
Method Detail

handleConnection

public void handleConnection(com.caucho.server.Connection conn)
                      throws java.io.IOException
Handle a connection. For now, each request needs its own connection. Profiling indicated that sharing connections was a lose.
Following copied from interface: com.caucho.server.ServerRequest
Parameters:
conn - Information about the connection, including buffered read and write streams.

start

protected void start(ReadStream s)
              throws java.io.IOException
Clears variables at the start of a new request.
Overrides:
start in class Request
Following copied from class: com.caucho.server.http.Request
Parameters:
s - the raw connection stream

getScheme

public java.lang.String getScheme()
Description copied from interface: ServletRequest
Returns the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.
Overrides:
getScheme in class Request
Following copied from interface: javax.servlet.ServletRequest
Returns:
a String containing the name of the scheme used to make this request

getMethodBuffer

public CharSegment getMethodBuffer()
Overrides:
getMethodBuffer in class Request

getUriBuffer

public byte[] getUriBuffer()
Overrides:
getUriBuffer in class Request

getUriLength

public int getUriLength()
Overrides:
getUriLength in class Request

getProtocolBuffer

public CharSegment getProtocolBuffer()
Overrides:
getProtocolBuffer in class Request

getHeaderBuffer

public CharSegment getHeaderBuffer(java.lang.String key)
Overrides:
getHeaderBuffer in class Request

getHeaderBuffer

public CharSegment getHeaderBuffer(char[] buf,
                                   int length)
Overrides:
getHeaderBuffer in class Request

setHeader

public void setHeader(java.lang.String key,
                      java.lang.String value)
Overrides:
setHeader in class Request

getHeaderBuffers

public void getHeaderBuffers(java.util.ArrayList values,
                             java.lang.String key)
Overrides:
getHeaderBuffers in class Request

getHeaderNames

public java.util.Enumeration getHeaderNames()
Description copied from class: Request
Enumerates the header keys
Overrides:
getHeaderNames in class Request
Following copied from interface: javax.servlet.http.HttpServletRequest
Returns:
an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the servlet container does not allow servlets to use this method, null

getRequestURI

public java.lang.String getRequestURI()
Returns the URI for the request, special casing the IIS issues. Because IIS already escapes the URI before sending it, the URI needs to be re-escaped.
Overrides:
getRequestURI in class Request
Following copied from interface: javax.servlet.http.HttpServletRequest
Returns:
a String containing the part of the URL from the protocol name up to the query string
See Also:
HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)

getServerName

public java.lang.String getServerName()
Description copied from interface: ServletRequest
Returns the host name of the server that received the request. For HTTP servlets, same as the value of the CGI variable SERVER_NAME.
Overrides:
getServerName in class Request
Following copied from interface: javax.servlet.ServletRequest
Returns:
a String containing the name of the server to which the request was sent

getServerPort

public int getServerPort()
Description copied from interface: ServletRequest
Returns the port number on which this request was received. For HTTP servlets, same as the value of the CGI variable SERVER_PORT.
Overrides:
getServerPort in class Request
Following copied from interface: javax.servlet.ServletRequest
Returns:
an integer specifying the port number

getRemoteAddr

public java.lang.String getRemoteAddr()
Description copied from interface: ServletRequest
Returns the Internet Protocol (IP) address of the client that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.
Overrides:
getRemoteAddr in class Request
Following copied from interface: javax.servlet.ServletRequest
Returns:
a String containing the IP address of the client that sent the request

getRemoteAddr

public void getRemoteAddr(CharBuffer cb)

getRemoteHost

public java.lang.String getRemoteHost()
Description copied from interface: ServletRequest
Returns the fully qualified name of the client that sent the request, or the IP address of the client if the name cannot be determined. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST.
Overrides:
getRemoteHost in class Request
Following copied from interface: javax.servlet.ServletRequest
Returns:
a String containing the fully qualified name of the client