summaryrefslogtreecommitdiffhomepage
path: root/src/java/nginx/unit/IncludeRequestWrapper.java
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-03-01 18:30:09 +0300
committerAndrei Belov <defan@nginx.com>2019-03-01 18:30:09 +0300
commit3c3720cba7154bc168cbd00c74817626bb53e140 (patch)
treeda1500f7c6bd5e90ecf45299b6f4b19a29d521cd /src/java/nginx/unit/IncludeRequestWrapper.java
parent315a864c27aa27a48c013c4a1ef67a099ffea894 (diff)
parentdf02b03824065389c73213b19736140442cf63bc (diff)
downloadunit-3c3720cba7154bc168cbd00c74817626bb53e140.tar.gz
unit-3c3720cba7154bc168cbd00c74817626bb53e140.tar.bz2
Merged with the default branch.
Diffstat (limited to 'src/java/nginx/unit/IncludeRequestWrapper.java')
-rw-r--r--src/java/nginx/unit/IncludeRequestWrapper.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/java/nginx/unit/IncludeRequestWrapper.java b/src/java/nginx/unit/IncludeRequestWrapper.java
new file mode 100644
index 00000000..67a51b24
--- /dev/null
+++ b/src/java/nginx/unit/IncludeRequestWrapper.java
@@ -0,0 +1,88 @@
+package nginx.unit;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletRequest;
+
+public class IncludeRequestWrapper implements DynamicPathRequest
+{
+ private final Request request_;
+
+ private final Object orig_servlet_path_attr;
+ private final Object orig_path_info_attr;
+ private final Object orig_uri_attr;
+ private final Object orig_context_path_attr;
+ private final Object orig_query_string_attr;
+
+ private final DispatcherType orig_dtype;
+
+ private String filter_path_;
+
+ public IncludeRequestWrapper(ServletRequest request)
+ {
+ if (request instanceof Request) {
+ request_ = (Request) request;
+ } else {
+ request_ = (Request) request.getAttribute(Request.BARE);
+ }
+
+ orig_servlet_path_attr = request_.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
+ orig_path_info_attr = request_.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);
+ orig_uri_attr = request_.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
+ orig_context_path_attr = request_.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH);
+ orig_query_string_attr = request_.getAttribute(RequestDispatcher.INCLUDE_QUERY_STRING);
+
+ orig_dtype = request_.getDispatcherType();
+
+ request_.setAttribute_(RequestDispatcher.INCLUDE_CONTEXT_PATH, request_.getContextPath());
+ }
+
+ @Override
+ public void setDispatcherType(DispatcherType type)
+ {
+ request_.setDispatcherType(type);
+ }
+
+ @Override
+ public void setServletPath(String servlet_path, String path_info)
+ {
+ setServletPath(servlet_path, servlet_path, path_info);
+ }
+
+ @Override
+ public void setServletPath(String filter_path, String servlet_path, String path_info)
+ {
+ request_.setAttribute_(RequestDispatcher.INCLUDE_SERVLET_PATH, servlet_path);
+ request_.setAttribute_(RequestDispatcher.INCLUDE_PATH_INFO, path_info);
+ filter_path_ = filter_path;
+ }
+
+ @Override
+ public void setRequestURI(String uri)
+ {
+ request_.setAttribute_(RequestDispatcher.INCLUDE_REQUEST_URI, uri);
+ }
+
+ @Override
+ public void setQueryString(String query)
+ {
+ request_.setAttribute_(RequestDispatcher.INCLUDE_QUERY_STRING, query);
+ }
+
+ @Override
+ public String getFilterPath()
+ {
+ return filter_path_;
+ }
+
+ public void close()
+ {
+ request_.setDispatcherType(orig_dtype);
+
+ request_.setAttribute_(RequestDispatcher.INCLUDE_SERVLET_PATH, orig_servlet_path_attr);
+ request_.setAttribute_(RequestDispatcher.INCLUDE_PATH_INFO, orig_path_info_attr);
+ request_.setAttribute_(RequestDispatcher.INCLUDE_REQUEST_URI, orig_uri_attr);
+ request_.setAttribute_(RequestDispatcher.INCLUDE_CONTEXT_PATH, orig_context_path_attr);
+ request_.setAttribute_(RequestDispatcher.INCLUDE_QUERY_STRING, orig_query_string_attr);
+ }
+}