ProxiedHttpMethod getMethod(HttpClient client, LaunchSession launchSession, RequestHandlerRequest request, URL target) {
ReverseProxyWebForward webForward = (ReverseProxyWebForward) launchSession.getResource();
ProxiedHttpMethod method;
VariableReplacement v = new VariableReplacement();
v.setRequest(request);
v.setSession(launchSession.getSession());
v.setPolicy(launchSession.getPolicy());
/**
* POST parameters are now not being
*/
if (!webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_NONE)
&& !webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_NONE)
&& !webForward.getFormType().equals("")
&& !webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_JAVASCRIPT)
&& !Boolean.TRUE.equals(launchSession.getAttribute(LAUNCH_ATTR_AUTH_POSTED))) {
/**
* This code will automatically submit form parameters. If it is a post,
* then we ignore the parameters request and use the webforward target.
*/
method = new ProxiedHttpMethod(webForward.getFormType(),
target.getFile(),
webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_POST) ? new MultiMap() : new MultiMap(request.getParameters()),
launchSession.getSession(),
webForward.getFormType().equals(WebForwardTypes.FORM_SUBMIT_POST));
if (webForward.getCharset() != null
&& !webForward.getCharset().equals("")
&& !webForward.getCharset().equals(WebForwardTypes.DEFAULT_ENCODING))
method.setCharsetEncoding(webForward.getCharset());
StringTokenizer tokens = new StringTokenizer(webForward.getFormParameters(), "\n");
int idx;
String param;
while (tokens.hasMoreTokens()) {
param = v.replace(tokens.nextToken().trim());
idx = param.indexOf('=');
if (idx > -1) {
method.addParameter(param.substring(0, idx), param.substring(idx + 1));
} else
method.addParameter(param, "");