Java Code Examples for io.vertx.core.http.HttpServerRequest#remoteAddress()

The following examples show how to use io.vertx.core.http.HttpServerRequest#remoteAddress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteHostAccessItem.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public void appendServerFormattedItem(ServerAccessLogEvent accessLogEvent, StringBuilder builder) {
  HttpServerRequest request = accessLogEvent.getRoutingContext().request();
  if (null == request || null == request.remoteAddress()
      || StringUtils.isEmpty(request.remoteAddress().host())) {
    builder.append(EMPTY_RESULT);
    return;
  }
  builder.append(request.remoteAddress().host());
}
 
Example 2
Source File: HttpServerRequestAdaptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public String getRemoteAddress(HttpServerRequest request) {
    final SocketAddress socketAddress = request.remoteAddress();
    if (socketAddress != null) {
        return socketAddress.toString();
    }
    return "unknown";
}
 
Example 3
Source File: AccessLogHandler.java    From mpns with Apache License 2.0 4 votes vote down vote up
private String getClientAddress(HttpServerRequest request) {
    SocketAddress address = request.remoteAddress();
    if (address == null) return null;
    return address.host();
}
 
Example 4
Source File: SockJSSession.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
synchronized void register(HttpServerRequest req, TransportListener lst) {
  this.transportCtx = vertx.getOrCreateContext();
  this.localAddress = req.localAddress();
  this.remoteAddress = req.remoteAddress();
  this.uri = req.uri();
  this.headers = BaseTransport.removeCookieHeaders(req.headers());
  if (closed) {
    // Closed by the application
    writeClosed(lst);
    // And close the listener request
    lst.close();
  } else if (this.listener != null) {
    writeClosed(lst, 2010, "Another connection still open");
    // And close the listener request
    lst.close();
  } else {

    cancelTimer();

    this.listener = lst;

    if (!openWritten) {
      writeOpen(lst);
      sockHandler.handle(this);
      handleCalled = true;
    }

    if (listener != null) {
      if (closed) {
        // Could have already been closed by the user
        writeClosed(lst);
        listener = null;
        lst.close();
      } else {
        if (!pendingWrites.isEmpty()) {
          writePendingMessages();
        }
      }
    }
  }
}