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

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

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

Request.getScheme介绍

暂无

代码示例

代码示例来源:origin: jersey/jersey

private URI getBaseUri(final Request request) {
  try {
    return new URI(request.getScheme(), null, request.getServerName(),
        request.getServerPort(), getBasePath(request), null, null);
  } catch (final URISyntaxException ex) {
    throw new IllegalArgumentException(ex);
  }
}

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String s, Request r, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException {
  String param;
  httpResponse.setContentType(TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
  Enumeration<?> e = httpRequest.getHeaderNames();
  while (e.hasMoreElements()) {
   param = e.nextElement().toString();
   if (param.startsWith("X-redirect") && !redirectDone.getAndSet(true)) {
    httpResponse.addHeader("Location", httpRequest.getHeader(param));
    httpResponse.setStatus(302);
    httpResponse.getOutputStream().flush();
    httpResponse.getOutputStream().close();
    return;
   }
  }
  if (r.getScheme().equalsIgnoreCase("https")) {
   httpResponse.addHeader("X-httpToHttps", "PASS");
   redirectDone.getAndSet(false);
  }
  httpResponse.setStatus(200);
  httpResponse.getOutputStream().flush();
  httpResponse.getOutputStream().close();
 }
}

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

public boolean isConfidential(Request request)
{
  return _forwarded && request.getScheme().equalsIgnoreCase(HttpSchemes.HTTPS);
}

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

public boolean isConfidential(Request request)
{
  return _forwarded && request.getScheme().equalsIgnoreCase(HttpSchemes.HTTPS);
}

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

public boolean isConfidential(Request request)
{
  return _forwarded && request.getScheme().equalsIgnoreCase(HttpSchemes.HTTPS);
}

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

public boolean isConfidential(Request request)
{
  return _forwarded && request.getScheme().equalsIgnoreCase(HttpSchemes.HTTPS);
}

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

public boolean isConfidential(Request request)
{
  return _forwarded && request.getScheme().equalsIgnoreCase(HttpSchemes.HTTPS);
}

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

@Override
public StringBuffer getRequestURL()
{
  final StringBuffer url = new StringBuffer(48);
  String scheme = getScheme();
  int port = getServerPort();
  url.append(scheme);
  url.append("://");
  url.append(getServerName());
  if (_port > 0 && ((scheme.equalsIgnoreCase(URIUtil.HTTP) && port != 80) || (scheme.equalsIgnoreCase(URIUtil.HTTPS) && port != 443)))
  {
    url.append(':');
    url.append(_port);
  }
  url.append(getRequestURI());
  return url;
}

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

@Override
public StringBuffer getRequestURL()
{
  final StringBuffer url = new StringBuffer(48);
  String scheme = getScheme();
  int port = getServerPort();
  url.append(scheme);
  url.append("://");
  url.append(getServerName());
  if (_port > 0 && ((scheme.equalsIgnoreCase(URIUtil.HTTP) && port != 80) || (scheme.equalsIgnoreCase(URIUtil.HTTPS) && port != 443)))
  {
    url.append(':');
    url.append(_port);
  }
  url.append(getRequestURI());
  return url;
}

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

@Override
public StringBuffer getRequestURL()
{
  final StringBuffer url = new StringBuffer(128);
  URIUtil.appendSchemeHostPort(url,getScheme(),getServerName(),getServerPort());
  url.append(getRequestURI());
  return url;
}

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

@Override
public StringBuffer getRequestURL()
{
  final StringBuffer url = new StringBuffer(128);
  URIUtil.appendSchemeHostPort(url,getScheme(),getServerName(),getServerPort());
  url.append(getRequestURI());
  return url;
}

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

@Override
public StringBuffer getRequestURL()
{
  final StringBuffer url = new StringBuffer(128);
  URIUtil.appendSchemeHostPort(url,getScheme(),getServerName(),getServerPort());
  url.append(getRequestURI());
  return url;
}

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

/**
 * Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and, but it does not include a
 * path.
 * <p>
 * Because this method returns a <code>StringBuffer</code>, not a string, you can modify the URL easily, for example, to append path and query parameters.
 *
 * This method is useful for creating redirect messages and for reporting errors.
 *
 * @return "scheme://host:port"
 */
public StringBuilder getRootURL()
{
  StringBuilder url = new StringBuilder(128);
  URIUtil.appendSchemeHostPort(url,getScheme(),getServerName(),getServerPort());
  return url;
}

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

/**
 * Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and, but it does not include a
 * path.
 * <p>
 * Because this method returns a <code>StringBuffer</code>, not a string, you can modify the URL easily, for example, to append path and query parameters.
 *
 * This method is useful for creating redirect messages and for reporting errors.
 *
 * @return "scheme://host:port"
 */
public StringBuilder getRootURL()
{
  StringBuilder url = new StringBuilder(128);
  URIUtil.appendSchemeHostPort(url,getScheme(),getServerName(),getServerPort());
  return url;
}

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

/**
 * Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and, but it does not include a
 * path.
 * <p>
 * Because this method returns a <code>StringBuffer</code>, not a string, you can modify the URL easily, for example, to append path and query parameters.
 *
 * This method is useful for creating redirect messages and for reporting errors.
 *
 * @return "scheme://host:port"
 */
public StringBuilder getRootURL()
{
  StringBuilder url = new StringBuilder(128);
  URIUtil.appendSchemeHostPort(url,getScheme(),getServerName(),getServerPort());
  return url;
}

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

@Override
public int getServerPort()
{
  HttpURI uri = _metadata.getURI();
  int port = (uri.getHost()==null)?findServerPort():uri.getPort();
  // If no port specified, return the default port for the scheme
  if (port <= 0)
  {
    if (getScheme().equalsIgnoreCase(URIUtil.HTTPS))
      return 443;
    return 80;
  }
  // return a specific port
  return port;
}

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

@Override
public int getServerPort()
{
  MetaData.Request metadata = _metaData;
  HttpURI uri = metadata==null?null:metadata.getURI();
  int port = (uri==null||uri.getHost()==null)?findServerPort():uri.getPort();
  // If no port specified, return the default port for the scheme
  if (port <= 0)
  {
    if (getScheme().equalsIgnoreCase(URIUtil.HTTPS))
      return 443;
    return 80;
  }
  // return a specific port
  return port;
}

代码示例来源:origin: com.teradata.airlift/http-server

@Test
public void testNoXForwardedProto()
    throws Exception
{
  final Request request = mock(Request.class);
  final Response response = mock(Response.class);
  final String protocol = "protocol";
  when(request.getScheme()).thenReturn("protocol");
  InMemoryEventClient eventClient = new InMemoryEventClient();
  DelimitedRequestLog logger = new DelimitedRequestLog(file.getAbsolutePath(), 1, Long.MAX_VALUE, null, eventClient);
  logger.log(request, response);
  logger.stop();
  List<Object> events = eventClient.getEvents();
  Assert.assertEquals(events.size(), 1);
  HttpRequestEvent event = (HttpRequestEvent) events.get(0);
  Assert.assertEquals(event.getProtocol(), protocol);
}

代码示例来源:origin: io.airlift/http-server

@Test
public void testNoXForwardedProto()
    throws Exception
{
  Request request = mock(Request.class);
  Response response = mock(Response.class);
  String protocol = "protocol";
  when(request.getScheme()).thenReturn("protocol");
  when(request.getHttpVersion()).thenReturn(HTTP_2);
  InMemoryEventClient eventClient = new InMemoryEventClient();
  DelimitedRequestLog logger = new DelimitedRequestLog(file.getAbsolutePath(), 1, 256, Long.MAX_VALUE, null, eventClient, false);
  logger.log(request, response, 0, 0, 0, new DoubleSummaryStats(new DoubleSummaryStatistics()));
  logger.stop();
  List<Object> events = eventClient.getEvents();
  assertEquals(events.size(), 1);
  HttpRequestEvent event = (HttpRequestEvent) events.get(0);
  assertEquals(event.getProtocol(), protocol);
}

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

@Override
public void customize(Connector connector, HttpConfiguration channelConfig, Request request)
{
  if (request.getHttpChannel().getEndPoint() instanceof DecryptedEndPoint)
  {
    
    if (request.getHttpURI().getScheme()==null)
      request.setScheme(HttpScheme.HTTPS.asString());
    
    SslConnection.DecryptedEndPoint ssl_endp = (DecryptedEndPoint)request.getHttpChannel().getEndPoint();
    SslConnection sslConnection = ssl_endp.getSslConnection();
    SSLEngine sslEngine=sslConnection.getSSLEngine();
    customize(sslEngine,request);
  }
  if (HttpScheme.HTTPS.is(request.getScheme()))
    customizeSecure(request);
}

相关文章

Request类方法