public class GCNProxyServlet
extends javax.servlet.http.HttpServlet
![]() |
![]() |
![]() |
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
GCNProxyServlet() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, serviceprivate 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
proxyURLBaseprivate String proxyURLHostPortPath
proxyURLBaseprivate org.apache.log4j.Logger logger
private org.apache.commons.httpclient.MultiThreadedHttpConnectionManager connectionManager
public void init()
GCNProxyServlet.init in class javax.servlet.GenericServletpublic void destroy()
destroy in interface javax.servlet.Servletdestroy in class javax.servlet.GenericServletpublic void doGet(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
throws IOException,
javax.servlet.ServletException
doGet in class javax.servlet.http.HttpServlethttpServletRequest - 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 clientIOException - 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.HttpServlethttpServletRequest - 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 clientIOException - 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 PostMethodIOException - 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 clientIOException - Can be thrown by the HttpClient.executeMethodjavax.servlet.ServletException - Can be thrown to indicate that another error has occurredpublic String getServletInfo()
getServletInfo in interface javax.servlet.ServletgetServletInfo in class javax.servlet.GenericServletprivate 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 servletUnsupportedEncodingException - the unsupported encoding exceptionprivate void initProxyURLBase()
throws MalformedURLException
MalformedURLException - the malformed url exceptionCopyright © 2014 Gentics Software GmbH. All Rights Reserved.