|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.gentics.portal.GCNProxyServlet
public class GCNProxyServlet
Implementation of a simple proxy servlet to the GCN backend.
![]() |
![]() |
![]() |
Field Summary | |
---|---|
private static int |
BUFFERSIZE
the Buffer Size for readers. |
private org.apache.commons.httpclient.MultiThreadedHttpConnectionManager |
connectionManager
shared connection manager instance. |
private static String[] |
FORWARD_COOKIES
Cookies to be forwarded. |
private static int |
HTTPPORT
http port. |
private org.apache.log4j.Logger |
logger
logger. |
private String |
proxyURLBase
The base URL we are proxying to. |
private String |
proxyURLHostPort
proxy URL without the protocol and path, will be constructed from. |
private String |
proxyURLHostPortPath
proxy URL without the protocol, will be constructed from. |
private static long |
serialVersionUID
Serialization UID. |
private static String |
STRING_CONTENT_LENGTH_HEADER_NAME
Key for content length header. |
private static String |
STRING_HOST_HEADER_NAME
Key for host header. |
private static String |
STRING_LOCATION_HEADER
Key for redirect location header. |
private static String |
TRANSFER_ENCODING_HEADER_NAME
Key for the transfer-encoding header. |
Constructor Summary | |
---|---|
GCNProxyServlet()
|
Method Summary | |
---|---|
void |
destroy()
|
void |
doGet(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
Performs an HTTP GET request. |
void |
doPost(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
Performs an HTTP POST request. |
private void |
executeProxyRequest(org.apache.commons.httpclient.HttpMethod httpMethodProxyRequest,
javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
Executes the HttpMethod passed in and sends the proxy response
back to the client via the given HttpServletResponse . |
private String |
getProxyURL(javax.servlet.http.HttpServletRequest httpServletRequest)
Get the proxy URL from the original request. |
String |
getServletInfo()
|
private void |
handleStandardPost(org.apache.commons.httpclient.methods.PostMethod postMethodProxyRequest,
javax.servlet.http.HttpServletRequest httpServletRequest)
Sets up the given PostMethod to send the same standard POST data
as was sent in the given HttpServletRequest . |
void |
init()
Initialize the GCNProxyServlet . |
private void |
initProxyURLBase()
Get the proxy URL from the portal configuration. |
private void |
setProxyRequestHeaders(javax.servlet.http.HttpServletRequest httpServletRequest,
org.apache.commons.httpclient.HttpMethod httpMethodProxyRequest)
Retrieves all of the headers from the servlet request and sets them on the proxy request. |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int BUFFERSIZE
private static final int HTTPPORT
private static final long serialVersionUID
private static final String STRING_LOCATION_HEADER
private static final String STRING_CONTENT_LENGTH_HEADER_NAME
private static final String TRANSFER_ENCODING_HEADER_NAME
private static final String STRING_HOST_HEADER_NAME
private static final String[] FORWARD_COOKIES
private String proxyURLBase
private String proxyURLHostPort
proxyURLBase
private String proxyURLHostPortPath
proxyURLBase
private org.apache.log4j.Logger logger
private org.apache.commons.httpclient.MultiThreadedHttpConnectionManager connectionManager
Constructor Detail |
---|
public GCNProxyServlet()
Method Detail |
---|
public void init()
GCNProxyServlet
.
init
in class javax.servlet.GenericServlet
public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
public void doGet(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws IOException, javax.servlet.ServletException
doGet
in class javax.servlet.http.HttpServlet
httpServletRequest
- The HttpServletRequest
object passed in by the servlet
engine representing the client request to be proxiedhttpServletResponse
- The HttpServletResponse
object by which we can send a
proxied response to the client
IOException
- Signals that an I/O exception has occurred.
javax.servlet.ServletException
- the servlet exceptionpublic void doPost(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws IOException, javax.servlet.ServletException
doPost
in class javax.servlet.http.HttpServlet
httpServletRequest
- The HttpServletRequest
object passed in by the servlet
engine representing the client request to be proxiedhttpServletResponse
- The HttpServletResponse
object by which we can send a
proxied response to the client
IOException
- Signals that an I/O exception has occurred.
javax.servlet.ServletException
- the servlet exceptionprivate void handleStandardPost(org.apache.commons.httpclient.methods.PostMethod postMethodProxyRequest, javax.servlet.http.HttpServletRequest httpServletRequest) throws IOException
PostMethod
to send the same standard POST data
as was sent in the given HttpServletRequest
.
postMethodProxyRequest
- The PostMethod
that we are configuring to send a
standard POST requesthttpServletRequest
- The HttpServletRequest
that contains the POST data to
be sent via the PostMethod
IOException
- Signals that an I/O exception has occurred.private void executeProxyRequest(org.apache.commons.httpclient.HttpMethod httpMethodProxyRequest, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws IOException, javax.servlet.ServletException
HttpMethod
passed in and sends the proxy response
back to the client via the given HttpServletResponse
.
httpMethodProxyRequest
- An object representing the proxy request to be madehttpServletRequest
- the http servlet requesthttpServletResponse
- An object by which we can send the proxied response back to
the client
IOException
- Can be thrown by the HttpClient
.executeMethod
javax.servlet.ServletException
- Can be thrown to indicate that another error has occurredpublic String getServletInfo()
getServletInfo
in interface javax.servlet.Servlet
getServletInfo
in class javax.servlet.GenericServlet
private void setProxyRequestHeaders(javax.servlet.http.HttpServletRequest httpServletRequest, org.apache.commons.httpclient.HttpMethod httpMethodProxyRequest)
httpServletRequest
- The request object representing the client's request to the
servlet enginehttpMethodProxyRequest
- The request that we are about to send to the proxy hostprivate String getProxyURL(javax.servlet.http.HttpServletRequest httpServletRequest) throws UnsupportedEncodingException
httpServletRequest
- original request made to the proxy servlet
UnsupportedEncodingException
- the unsupported encoding exceptionprivate void initProxyURLBase() throws MalformedURLException
MalformedURLException
- the malformed url exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |