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

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

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

Request.getRemoteAddr介绍

暂无

代码示例

代码示例来源:origin: jphp-group/jphp

@Signature
public String remoteAddress() {
  return request.getRemoteAddr();
}

代码示例来源:origin: apache/incubator-druid

@Override
 public void log(Request request, Response response)
 {
  if (logger.isDebugEnabled()) {
   logger.debug(
     "%s %s %s %s",
     request.getRemoteAddr(),
     request.getMethod(),
     request.getHttpURI().toString(),
     request.getProtocol()
   );
  }
 }
}

代码示例来源:origin: i2p/i2p.i2p

addr = request.getRemoteAddr();

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

@Override
public String getRemoteAddr()
{
  if (_remoteAddr != null)
    return _remoteAddr;
  if (_remoteHost != null)
    return _remoteHost;
  return super.getRemoteAddr();
}

代码示例来源:origin: org.keycloak/spring-boot-container-bundle

@Override
public String getRemoteAddr() {
  return request.getRemoteAddr();
}

代码示例来源:origin: org.keycloak/keycloak-jetty-adapter-spi

@Override
public String getRemoteAddr() {
  return request.getRemoteAddr();
}

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

public static class Filter implements ContainerRequestFilter {

  @Context
  private javax.inject.Provider<Request> requestProvider;

  @Override
  public void filter(ContainerRequestContext requestContext) throws IOException {
    final Request request = requestProvider.get();
    System.out.println(request.getRemoteAddr());
  } 
}

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

public String getRemoteHost()
{
  if (_dns)
  {
    if (_remoteHost != null)
    {
      return _remoteHost;
    }
    return _endp == null?null:_endp.getRemoteHost();
  }
  return getRemoteAddr();
}

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

public String getRemoteHost()
{
  if (_dns)
  {
    if (_remoteHost != null)
    {
      return _remoteHost;
    }
    return _endp == null?null:_endp.getRemoteHost();
  }
  return getRemoteAddr();
}

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

public String getRemoteHost()
{
  if (_dns)
  {
    if (_remoteHost != null)
    {
      return _remoteHost;
    }
    return _endp == null?null:_endp.getRemoteHost();
  }
  return getRemoteAddr();
}

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

public String getRemoteHost()
{
  if (_dns)
  {
    if (_remoteHost != null)
    {
      return _remoteHost;
    }
    return _endp == null?null:_endp.getRemoteHost();
  }
  return getRemoteAddr();
}

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

public String getRemoteHost()
{
  if (_dns)
  {
    if (_remoteHost != null)
    {
      return _remoteHost;
    }
    return _endp == null?null:_endp.getRemoteHost();
  }
  return getRemoteAddr();
}

代码示例来源:origin: com.nitorcreations/willow-logging-jetty

@Override
public String getAddress() {
 String addr = null;
 if (preferProxiedForAddress) {
  addr = request.getHeader(HttpHeader.X_FORWARDED_FOR.toString());
 }
 if (addr == null) {
  addr = request.getRemoteAddr();
 }
 return addr;
}

代码示例来源:origin: com.googlecode.mycontainer/mycontainer-web

public void log(Request request, Response response) {
  if (LOG.isInfoEnabled()) {
    String remoteAddr = request.getRemoteAddr();
    String method = request.getMethod();
    String protocol = request.getProtocol();
    StringBuffer url = request.getRequestURL();
    LOG.info("Request: " + protocol + " " + method + " " + remoteAddr
        + " " + url);
  }
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jetty

@Override
public String getClientAddress() {
  return getConnection().getRequest().getRemoteAddr();
}

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

@Test
public void testNoXForwardedFor()
    throws Exception
{
  final Request request = mock(Request.class);
  final Response response = mock(Response.class);
  final String clientIp = "1.1.1.1";
  when(request.getRemoteAddr()).thenReturn(clientIp);
  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.getClientAddress(), clientIp);
}

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

@Override
 public void log(Request request, Response response)
 {
  if (logger.isDebugEnabled()) {
   logger.debug(
     "%s %s %s %s",
     request.getRemoteAddr(),
     request.getMethod(),
     request.getHttpURI().toString(),
     request.getProtocol()
   );
  }
 }
}

代码示例来源:origin: org.apache.druid/druid-server

@Override
 public void log(Request request, Response response)
 {
  if (logger.isDebugEnabled()) {
   logger.debug(
     "%s %s %s %s",
     request.getRemoteAddr(),
     request.getMethod(),
     request.getHttpURI().toString(),
     request.getProtocol()
   );
  }
 }
}

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

@Test
  public void testXForwardedForSkipPrivateAddresses()
      throws Exception
  {
    Request request = mock(Request.class);
    Response response = mock(Response.class);
    String clientIp = "1.1.1.1";

    when(request.getRemoteAddr()).thenReturn("9.9.9.9");
    when(request.getHeaders("X-FORWARDED-FOR")).thenReturn(Collections.enumeration(ImmutableList.of(clientIp, "192.168.1.2, 172.16.0.1", "169.254.1.2, 127.1.2.3", "10.1.2.3")));
    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.getClientAddress(), clientIp);
  }
}

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

@Test
public void testNoXForwardedFor()
    throws Exception
{
  Request request = mock(Request.class);
  Response response = mock(Response.class);
  String clientIp = "1.1.1.1";
  when(request.getRemoteAddr()).thenReturn(clientIp);
  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.getClientAddress(), clientIp);
}

相关文章

Request类方法