Skip to content

Expose local address in reactive ServerHttpRequest #24174

@bilak

Description

@bilak

Hello,
is there any way how to obtain localAddr from incoming request? I mean if I have multiple virtual addresses/interfaces on host and I need to distinguish on which address was the request accepted.

Only way which I found now is little hack with netty's HttpServerRequest.

if ((((AbstractServerHttpRequest) exchange.getRequest()).getNativeRequest()) instanceof HttpServerRequest) {
    final InetSocketAddress localAddress = ((HttpServerRequest) (((AbstractServerHttpRequest) exchange.getRequest()).getNativeRequest())).hostAddress();
    logger.debug("!!! Hostname {}, HostString {}, Address {}",
            localAddress.getHostName(),
            localAddress.getHostString(),
            localAddress.getAddress()
    );
}

Is there any general approach?

Thanks

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions