org.eclipse.jetty.server.Request.getContext()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中org.eclipse.jetty.server.Request.getContext方法的一些代码示例,展示了Request.getContext的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getContext方法的具体详情如下:
包路径:org.eclipse.jetty.server.Request
类名称:Request
方法名:getContext

Request.getContext介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

  1. import java.util.Arrays;
  2. import java.lang.reflect.Field;
  3. import org.apache.catalina.connector.Request;
  4. import org.apache.catalina.connector.RequestFacade;
  5. import org.apache.catalina.core.StandardContext;
  6. ...
  7. // ugly reflection hack - do NOT use
  8. final RequestFacade tomcatRequestFacade = (RequestFacade) req;
  9. final Class<? extends RequestFacade> requestFacadeClass =
  10. tomcatRequestFacade.getClass();
  11. try {
  12. final Field field = requestFacadeClass.getDeclaredField("request");
  13. field.setAccessible(true);
  14. final Request tomcatRequest = (Request) field.get(tomcatRequestFacade);
  15. final StandardContext standardContext =
  16. (StandardContext) tomcatRequest.getContext();
  17. final String[] mappings = standardContext.findMimeMappings();
  18. logger.info("mapping list: {}", Arrays.asList(mappings));
  19. } catch (final Exception e) {
  20. logger.error("", e);
  21. }

代码示例来源:origin: Nextdoor/bender

  1. /**
  2. * @see javax.servlet.http.HttpServletRequest#upgrade(java.lang.Class)
  3. */
  4. @Override
  5. public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException
  6. {
  7. if (getContext() == null)
  8. throw new ServletException ("Unable to instantiate "+handlerClass);
  9. try
  10. {
  11. //Instantiate an instance and inject it
  12. T h = getContext().createInstance(handlerClass);
  13. //TODO handle the rest of the upgrade process
  14. return h;
  15. }
  16. catch (Exception e)
  17. {
  18. if (e instanceof ServletException)
  19. throw (ServletException)e;
  20. throw new ServletException(e);
  21. }
  22. }
  23. }

代码示例来源:origin: jenkinsci/winstone

  1. public MultiPartsHttpParser(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir, Request request) throws IOException
  2. {
  3. _httpParser = new MultiPartFormInputStream(in, contentType, config, contextTmpDir);
  4. _context = request.getContext();
  5. _httpParser.getParts();
  6. }

代码示例来源:origin: theonedev/onedev

  1. @Override
  2. public void setLocale(Locale locale)
  3. {
  4. if (locale == null || isCommitted() || isIncluding())
  5. return;
  6. _locale = locale;
  7. _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-'));
  8. if (_outputType != OutputType.NONE)
  9. return;
  10. if (_channel.getRequest().getContext() == null)
  11. return;
  12. String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
  13. if (charset != null && charset.length() > 0 && __localeOverride.contains(_encodingFrom))
  14. setCharacterEncoding(charset,EncodingFrom.SET_LOCALE);
  15. }

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

  1. @Override
  2. public void setLocale(Locale locale)
  3. {
  4. if (locale == null || isCommitted() || isIncluding())
  5. return;
  6. _locale = locale;
  7. _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-'));
  8. if (_outputType != OutputType.NONE)
  9. return;
  10. if (_channel.getRequest().getContext() == null)
  11. return;
  12. String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
  13. if (charset != null && charset.length() > 0 && _characterEncoding == null)
  14. setCharacterEncoding(charset);
  15. }

代码示例来源:origin: jenkinsci/winstone

  1. @Override
  2. public void setLocale(Locale locale)
  3. {
  4. if (locale == null || isCommitted() || isIncluding())
  5. return;
  6. _locale = locale;
  7. _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-'));
  8. if (_outputType != OutputType.NONE)
  9. return;
  10. if (_channel.getRequest().getContext() == null)
  11. return;
  12. String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
  13. if (charset != null && charset.length() > 0 && __localeOverride.contains(_encodingFrom))
  14. setCharacterEncoding(charset,EncodingFrom.SET_LOCALE);
  15. }

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

  1. @Override
  2. public void setLocale(Locale locale)
  3. {
  4. if (locale == null || isCommitted() || isIncluding())
  5. return;
  6. _locale = locale;
  7. _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-'));
  8. if (_outputType != OutputType.NONE)
  9. return;
  10. if (_channel.getRequest().getContext() == null)
  11. return;
  12. String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
  13. if (charset != null && charset.length() > 0 && _characterEncoding == null)
  14. setCharacterEncoding(charset);
  15. }

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server

  1. @Override
  2. public void setLocale(Locale locale)
  3. {
  4. if (locale == null || isCommitted() || isIncluding())
  5. return;
  6. _locale = locale;
  7. _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-'));
  8. if (_outputType != OutputType.NONE)
  9. return;
  10. if (_channel.getRequest().getContext() == null)
  11. return;
  12. String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
  13. if (charset != null && charset.length() > 0 && !_explicitEncoding)
  14. setCharacterEncoding(charset,false);
  15. }

代码示例来源:origin: Nextdoor/bender

  1. @Override
  2. public void setLocale(Locale locale)
  3. {
  4. if (locale == null || isCommitted() || isIncluding())
  5. return;
  6. _locale = locale;
  7. _fields.put(HttpHeader.CONTENT_LANGUAGE, locale.toString().replace('_', '-'));
  8. if (_outputType != OutputType.NONE)
  9. return;
  10. if (_channel.getRequest().getContext() == null)
  11. return;
  12. String charset = _channel.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);
  13. if (charset != null && charset.length() > 0 && !_explicitEncoding)
  14. setCharacterEncoding(charset,false);
  15. }

代码示例来源:origin: jenkinsci/winstone

  1. public MultiPartsUtilParser(InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir, Request request) throws IOException
  2. {
  3. _utilParser = new MultiPartInputStreamParser(in, contentType, config, contextTmpDir);
  4. _context = request.getContext();
  5. _utilParser.getParts();
  6. EnumSet<NonCompliance> nonComplianceWarnings = _utilParser.getNonComplianceWarnings();
  7. if (!nonComplianceWarnings.isEmpty())
  8. {
  9. @SuppressWarnings("unchecked")
  10. List<String> violations = (List<String>)request.getAttribute(HttpCompliance.VIOLATIONS_ATTR);
  11. if (violations==null)
  12. {
  13. violations = new ArrayList<>();
  14. request.setAttribute(HttpCompliance.VIOLATIONS_ATTR,violations);
  15. }
  16. for(NonCompliance nc : nonComplianceWarnings)
  17. violations.add(nc.name()+": "+nc.getURL());
  18. }
  19. }

代码示例来源:origin: stackoverflow.com

  1. context = request.getContext();
  2. Principal principal = context.getRealm().authenticate("*", "*");

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

  1. return;
  2. if (_connection.getRequest().getContext()==null)
  3. return;
  4. String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

  1. return;
  2. if (_connection.getRequest().getContext()==null)
  3. return;
  4. String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server

  1. return;
  2. if (_connection.getRequest().getContext()==null)
  3. return;
  4. String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus

  1. return;
  2. if (_connection.getRequest().getContext()==null)
  3. return;
  4. String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);

代码示例来源:origin: org.eclipse.jetty/server

  1. return;
  2. if (_connection.getRequest().getContext()==null)
  3. return;
  4. String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale);

代码示例来源:origin: jenkinsci/winstone

  1. code != SC_PARTIAL_CONTENT && code >= SC_OK)
  2. ContextHandler.Context context = request.getContext();
  3. ContextHandler contextHandler = context == null ? _channel.getState().getContextHandler() : context.getContextHandler();
  4. request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE, code);

代码示例来源:origin: theonedev/onedev

  1. code>=SC_OK)
  2. ErrorHandler error_handler = ErrorHandler.getErrorHandler(_channel.getServer(),request.getContext()==null?null:request.getContext().getContextHandler());
  3. if (error_handler!=null)

代码示例来源:origin: Nextdoor/bender

  1. code>=SC_OK)
  2. ErrorHandler error_handler = ErrorHandler.getErrorHandler(_channel.getServer(),request.getContext()==null?null:request.getContext().getContextHandler());
  3. if (error_handler!=null)

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

  1. ContextHandler.Context context = request.getContext();
  2. if (context!=null)
  3. error_handler=context.getContextHandler().getErrorHandler();

相关文章

Request类方法