comparison src/org/eclipse/jetty/server/Request.java @ 991:688c39c50ee3

simplify ContextHandler
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 18 Oct 2016 00:22:46 -0600
parents 83cc6e05a58f
children 4e9d373bf6e9
comparison
equal deleted inserted replaced
990:83cc6e05a58f 991:688c39c50ee3
119 * attribute. The number of parameters keys is limited by {@link ContextHandler#getMaxFormKeys()} or if there is no context then the 119 * attribute. The number of parameters keys is limited by {@link ContextHandler#getMaxFormKeys()} or if there is no context then the
120 * "org.eclipse.jetty.server.Request.maxFormKeys" {@link Server} attribute. 120 * "org.eclipse.jetty.server.Request.maxFormKeys" {@link Server} attribute.
121 * 121 *
122 * 122 *
123 */ 123 */
124 public class Request implements HttpServletRequest 124 public final class Request implements HttpServletRequest
125 { 125 {
126 public static final String __MULTIPART_CONFIG_ELEMENT = "org.eclipse.multipartConfig"; 126 public static final String __MULTIPART_CONFIG_ELEMENT = "org.eclipse.multipartConfig";
127 public static final String __MULTIPART_INPUT_STREAM = "org.eclipse.multiPartInputStream"; 127 public static final String __MULTIPART_INPUT_STREAM = "org.eclipse.multiPartInputStream";
128 public static final String __MULTIPART_CONTEXT = "org.eclipse.multiPartContext"; 128 public static final String __MULTIPART_CONTEXT = "org.eclipse.multiPartContext";
129 private static final Logger LOG = LoggerFactory.getLogger(Request.class); 129 private static final Logger LOG = LoggerFactory.getLogger(Request.class);
135 private volatile Attributes _attributes; 135 private volatile Attributes _attributes;
136 private MultiMap<String> _baseParameters; 136 private MultiMap<String> _baseParameters;
137 private String _characterEncoding; 137 private String _characterEncoding;
138 protected AbstractHttpConnection _connection; 138 protected AbstractHttpConnection _connection;
139 private ContextHandler.Context _context; 139 private ContextHandler.Context _context;
140 private boolean _newContext;
141 private String _contextPath; 140 private String _contextPath;
142 private CookieCutter _cookies; 141 private CookieCutter _cookies;
143 private boolean _cookiesExtracted = false; 142 private boolean _cookiesExtracted = false;
144 private DispatcherType _dispatcherType;
145 private EndPoint _endp; 143 private EndPoint _endp;
146 private boolean _handled = false; 144 private boolean _handled = false;
147 private int _inputState = __NONE; 145 private int _inputState = __NONE;
148 private String _method; 146 private String _method;
149 private MultiMap<String> _parameters; 147 private MultiMap<String> _parameters;
219 try 217 try
220 { 218 {
221 int maxFormContentSize = -1; 219 int maxFormContentSize = -1;
222 int maxFormKeys = -1; 220 int maxFormKeys = -1;
223 221
224 if (_context != null)
225 {
226 maxFormContentSize = _context.getContextHandler().getMaxFormContentSize();
227 maxFormKeys = _context.getContextHandler().getMaxFormKeys();
228 }
229
230 if (maxFormContentSize < 0) 222 if (maxFormContentSize < 0)
231 { 223 {
232 maxFormContentSize = 200000; 224 maxFormContentSize = 200000;
233 } 225 }
234 226
452 public long getDateHeader(String name) 444 public long getDateHeader(String name)
453 { 445 {
454 return _connection._requestFields.getDateField(name); 446 return _connection._requestFields.getDateField(name);
455 } 447 }
456 448
457 /* ------------------------------------------------------------ */ 449 @Override
458 public DispatcherType getDispatcherType() 450 public DispatcherType getDispatcherType()
459 { 451 {
460 return _dispatcherType; 452 throw new UnsupportedOperationException();
461 } 453 }
462 454
463 /* ------------------------------------------------------------ */ 455 /* ------------------------------------------------------------ */
464 /* 456 /*
465 * @see javax.servlet.http.HttpServletRequest#getHeader(java.lang.String) 457 * @see javax.servlet.http.HttpServletRequest#getHeader(java.lang.String)
706 public String getPathInfo() 698 public String getPathInfo()
707 { 699 {
708 return _pathInfo; 700 return _pathInfo;
709 } 701 }
710 702
711 /* ------------------------------------------------------------ */ 703 @Override
712 /*
713 * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
714 */
715 public String getPathTranslated() 704 public String getPathTranslated()
716 { 705 {
717 if (_pathInfo == null || _context == null) 706 return null;
718 return null;
719 return _context.getRealPath(_pathInfo);
720 } 707 }
721 708
722 /* ------------------------------------------------------------ */ 709 /* ------------------------------------------------------------ */
723 /* 710 /*
724 * @see javax.servlet.ServletRequest#getProtocol() 711 * @see javax.servlet.ServletRequest#getProtocol()
772 } 759 }
773 _inputState = __READER; 760 _inputState = __READER;
774 return _reader; 761 return _reader;
775 } 762 }
776 763
777 /* ------------------------------------------------------------ */ 764 @Override
778 /*
779 * @see javax.servlet.ServletRequest#getRealPath(java.lang.String)
780 */
781 public String getRealPath(String path) 765 public String getRealPath(String path)
782 { 766 {
783 if (_context == null) 767 return null;
784 return null;
785 return _context.getRealPath(path);
786 } 768 }
787 769
788 /* ------------------------------------------------------------ */ 770 /* ------------------------------------------------------------ */
789 /* 771 /*
790 * @see javax.servlet.ServletRequest#getRemoteAddr() 772 * @see javax.servlet.ServletRequest#getRemoteAddr()
824 if (p == null) 806 if (p == null)
825 return null; 807 return null;
826 return p.getName(); 808 return p.getName();
827 } 809 }
828 810
829 /* ------------------------------------------------------------ */ 811 @Override
830 /*
831 * @see javax.servlet.ServletRequest#getRequestDispatcher(java.lang.String)
832 */
833 public RequestDispatcher getRequestDispatcher(String path) 812 public RequestDispatcher getRequestDispatcher(String path)
834 { 813 {
835 throw new UnsupportedOperationException(); 814 throw new UnsupportedOperationException();
836 } 815 }
837 816
1034 return 80; 1013 return 80;
1035 } 1014 }
1036 return _port; 1015 return _port;
1037 } 1016 }
1038 1017
1018 @Override
1039 public ServletContext getServletContext() 1019 public ServletContext getServletContext()
1040 { 1020 {
1041 return _context; 1021 throw new UnsupportedOperationException();
1042 } 1022 }
1043 1023
1044 /* ------------------------------------------------------------ */ 1024 /* ------------------------------------------------------------ */
1045 /* 1025 /*
1046 * @see javax.servlet.http.HttpServletRequest#getServletPath() 1026 * @see javax.servlet.http.HttpServletRequest#getServletPath()
1330 * @param context 1310 * @param context
1331 * context object 1311 * context object
1332 */ 1312 */
1333 public void setContext(Context context) 1313 public void setContext(Context context)
1334 { 1314 {
1335 _newContext = _context != context;
1336 _context = context; 1315 _context = context;
1337 }
1338
1339 /* ------------------------------------------------------------ */
1340 /**
1341 * @return True if this is the first call of {@link #takeNewContext()} since the last
1342 * {@link #setContext(org.eclipse.jetty.server.handler.ContextHandler.Context)} call.
1343 */
1344 public boolean takeNewContext()
1345 {
1346 boolean nc = _newContext;
1347 _newContext = false;
1348 return nc;
1349 } 1316 }
1350 1317
1351 /* ------------------------------------------------------------ */ 1318 /* ------------------------------------------------------------ */
1352 /** 1319 /**
1353 * Sets the "context path" for this request 1320 * Sets the "context path" for this request
1367 public void setCookies(Cookie[] cookies) 1334 public void setCookies(Cookie[] cookies)
1368 { 1335 {
1369 if (_cookies == null) 1336 if (_cookies == null)
1370 _cookies = new CookieCutter(); 1337 _cookies = new CookieCutter();
1371 _cookies.setCookies(cookies); 1338 _cookies.setCookies(cookies);
1372 }
1373
1374 /* ------------------------------------------------------------ */
1375 public void setDispatcherType(DispatcherType type)
1376 {
1377 _dispatcherType = type;
1378 } 1339 }
1379 1340
1380 /* ------------------------------------------------------------ */ 1341 /* ------------------------------------------------------------ */
1381 public void setHandled(boolean h) 1342 public void setHandled(boolean h)
1382 { 1343 {