summaryrefslogtreecommitdiffhomepage
path: root/src/java/nginx/unit/IncludeRequestWrapper.java
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@gmail.com>2019-02-28 18:02:42 +0300
committerMax Romanov <max.romanov@gmail.com>2019-02-28 18:02:42 +0300
commit5bfdebb9e4161a689113d73775498949a09d7fb5 (patch)
treefcb69169e3da983db0eb1f48d2dccc2ac2ff867b /src/java/nginx/unit/IncludeRequestWrapper.java
parentec7319d32c9c41597a99a9422ff324c97a92bb21 (diff)
downloadunit-5bfdebb9e4161a689113d73775498949a09d7fb5.tar.gz
unit-5bfdebb9e4161a689113d73775498949a09d7fb5.tar.bz2
Introducing Java Servlet Container beta.
Diffstat (limited to '')
-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);
+ }
+}