import java.util.Arrays; import java.lang.reflect.Field; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.RequestFacade; import org.apache.catalina.core.StandardContext; ... // ugly reflection hack - do NOT use final RequestFacade tomcatRequestFacade = (RequestFacade) req; final Class<? extends RequestFacade> requestFacadeClass = tomcatRequestFacade.getClass(); try { final Field field = requestFacadeClass.getDeclaredField("request"); field.setAccessible(true); final Request tomcatRequest = (Request) field.get(tomcatRequestFacade); final StandardContext standardContext = (StandardContext) tomcatRequest.getContext(); final String[] mappings = standardContext.findMimeMappings(); logger.info("mapping list: {}", Arrays.asList(mappings)); } catch (final Exception e) { logger.error("", e); }
/** * @see javax.servlet.http.HttpServletRequest#upgrade(java.lang.Class) */ @Override public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException { if (getContext() == null) throw new ServletException ("Unable to instantiate "+handlerClass); try { //Instantiate an instance and inject it T h = getContext().createInstance(handlerClass); //TODO handle the rest of the upgrade process return h; } catch (Exception e) { if (e instanceof ServletException) throw (ServletException)e; throw new ServletException(e); } } }
public MultiPartsHttpParser(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir, Request request) throws IOException { _httpParser = new MultiPartFormInputStream(in, contentType, config, contextTmpDir); _context = request.getContext(); _httpParser.getParts(); }
@Override public void setLocale(Locale locale) { if (locale == null || isCommitted() || isIncluding()) return; _locale = locale; _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-')); if (_outputType != OutputType.NONE) return; if (_channel.getRequest().getContext() == null) return; String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale); if (charset != null && charset.length() > 0 && __localeOverride.contains(_encodingFrom)) setCharacterEncoding(charset,EncodingFrom.SET_LOCALE); }
@Override public void setLocale(Locale locale) { if (locale == null || isCommitted() || isIncluding()) return; _locale = locale; _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-')); if (_outputType != OutputType.NONE) return; if (_channel.getRequest().getContext() == null) return; String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale); if (charset != null && charset.length() > 0 && _characterEncoding == null) setCharacterEncoding(charset); }
@Override public void setLocale(Locale locale) { if (locale == null || isCommitted() || isIncluding()) return; _locale = locale; _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-')); if (_outputType != OutputType.NONE) return; if (_channel.getRequest().getContext() == null) return; String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale); if (charset != null && charset.length() > 0 && __localeOverride.contains(_encodingFrom)) setCharacterEncoding(charset,EncodingFrom.SET_LOCALE); }
@Override public void setLocale(Locale locale) { if (locale == null || isCommitted() || isIncluding()) return; _locale = locale; _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-')); if (_outputType != OutputType.NONE) return; if (_channel.getRequest().getContext() == null) return; String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale); if (charset != null && charset.length() > 0 && _characterEncoding == null) setCharacterEncoding(charset); }
@Override public void setLocale(Locale locale) { if (locale == null || isCommitted() || isIncluding()) return; _locale = locale; _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-')); if (_outputType != OutputType.NONE) return; if (_channel.getRequest().getContext() == null) return; String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale); if (charset != null && charset.length() > 0 && !_explicitEncoding) setCharacterEncoding(charset,false); }
@Override public void setLocale(Locale locale) { if (locale == null || isCommitted() || isIncluding()) return; _locale = locale; _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-')); if (_outputType != OutputType.NONE) return; if (_channel.getRequest().getContext() == null) return; String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale); if (charset != null && charset.length() > 0 && !_explicitEncoding) setCharacterEncoding(charset,false); }
public MultiPartsUtilParser(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir, Request request) throws IOException { _utilParser = new MultiPartInputStreamParser(in, contentType, config, contextTmpDir); _context = request.getContext(); _utilParser.getParts(); EnumSet<NonCompliance> nonComplianceWarnings = _utilParser.getNonComplianceWarnings(); if (!nonComplianceWarnings.isEmpty()) { @SuppressWarnings("unchecked") List<String> violations = (List<String>)request.getAttribute(HttpCompliance.VIOLATIONS_ATTR); if (violations==null) { violations = new ArrayList<>(); request.setAttribute(HttpCompliance.VIOLATIONS_ATTR,violations); } for(NonCompliance nc : nonComplianceWarnings) violations.add(nc.name()+": "+nc.getURL()); } }
context = request.getContext(); Principal principal = context.getRealm().authenticate("*", "*");
return; if (_connection.getRequest().getContext()==null) return; String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
return; if (_connection.getRequest().getContext()==null) return; String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
return; if (_connection.getRequest().getContext()==null) return; String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
return; if (_connection.getRequest().getContext()==null) return; String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
return; if (_connection.getRequest().getContext()==null) return; String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
code != SC_PARTIAL_CONTENT && code >= SC_OK) ContextHandler.Context context = request.getContext(); ContextHandler contextHandler = context == null ? _channel.getState().getContextHandler() : context.getContextHandler(); request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE, code);
code>=SC_OK) ErrorHandler error_handler = ErrorHandler.getErrorHandler(_channel.getServer(),request.getContext()==null?null:request.getContext().getContextHandler()); if (error_handler!=null)
code>=SC_OK) ErrorHandler error_handler = ErrorHandler.getErrorHandler(_channel.getServer(),request.getContext()==null?null:request.getContext().getContextHandler()); if (error_handler!=null)
ContextHandler.Context context = request.getContext(); if (context!=null) error_handler=context.getContextHandler().getErrorHandler();