1
|
|
/* Generated by AspectJ version 1.0.5 */
|
2
|
|
package org.apache.cactus.server;
|
3
|
|
import java.io.UnsupportedEncodingException;
|
4
|
|
import java.util.Map;
|
5
|
|
import javax.servlet.http.HttpServletRequest;
|
6
|
|
import org.apache.cactus.ServletURL;
|
7
|
|
|
8
|
|
/**
|
9
|
|
* Encapsulation class for the Servlet 2.3 API <code>HttpServletRequest</code>.
|
10
|
|
* This is an implementation that delegates all the call to the
|
11
|
|
* <code>HttpServletRequest</code> object passed in the constructor except for
|
12
|
|
* some overiden methods which are use to simulate a URL. This is to be able to
|
13
|
|
* simulate any URL that would have been used to call the test method : if this
|
14
|
|
* was not done, the URL that would be returned (by calling the
|
15
|
|
* <code>getRequestURI()</code> method or others alike) would be the URL of the
|
16
|
|
* Cactus redirector servlet and not a URL that the test case want to simulate.
|
17
|
|
*
|
18
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
19
|
|
*
|
20
|
|
* @version $Id: HttpServletRequestWrapper.java,v 1.4 2002/07/21 12:09:16 vmassol Exp $
|
21
|
|
*/
|
22
|
|
public class HttpServletRequestWrapper extends AbstractHttpServletRequestWrapper {
|
23
|
|
/**
|
24
|
|
* Construct an <code>HttpServletRequest</code> instance that delegates
|
25
|
|
* it's method calls to the request object passed as parameter and that
|
26
|
|
* uses the URL passed as parameter to simulate a URL from which the request
|
27
|
|
* would come from.
|
28
|
|
*
|
29
|
|
* @param theRequest the real HTTP request
|
30
|
|
* @param theURL the URL to simulate or <code>null</code> if none
|
31
|
|
*/
|
32
|
0
|
public HttpServletRequestWrapper(HttpServletRequest theRequest, ServletURL theURL) {
|
33
|
0
|
super(theRequest, theURL);
|
34
|
|
;
|
35
|
|
}
|
36
|
|
/**
|
37
|
|
* @return the URL from the simulated URL or the real URL
|
38
|
|
* if a simulation URL has not been defined.
|
39
|
|
* @see HttpServletRequest#getRequestURL()
|
40
|
|
*/
|
41
|
0
|
public StringBuffer getRequestURL() {
|
42
|
0
|
StringBuffer result;
|
43
|
0
|
if (this.url != null) {
|
44
|
0
|
result = new StringBuffer(this.url.getProtocol() + "://" + this.getServerName() + ":" +
|
45
|
|
this.getServerPort() + this.getContextPath() + this.getServletPath() + this.getPathInfo(
|
46
|
|
));
|
47
|
|
} else {
|
48
|
0
|
result = this.request.getRequestURL();
|
49
|
|
}
|
50
|
0
|
return result;
|
51
|
|
}
|
52
|
|
|
53
|
|
/**
|
54
|
|
* @see HttpServletRequest#setCharacterEncoding(String)
|
55
|
|
*/
|
56
|
0
|
public void setCharacterEncoding(String theEnvironment) throws UnsupportedEncodingException {
|
57
|
0
|
this.request.setCharacterEncoding(theEnvironment);
|
58
|
|
}
|
59
|
|
|
60
|
|
/**
|
61
|
|
* @see HttpServletRequest#getParameterMap()
|
62
|
|
*/
|
63
|
0
|
public Map getParameterMap() {
|
64
|
0
|
return this.request.getParameterMap();
|
65
|
|
}
|
66
|
|
|
67
|
|
}
|