Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get remote address from HttpRequest #50

Closed
roded opened this issue Feb 6, 2016 · 12 comments
Closed

Get remote address from HttpRequest #50

roded opened this issue Feb 6, 2016 · 12 comments
Assignees

Comments

@roded
Copy link
Contributor

roded commented Feb 6, 2016

Hi,
Can the remote address be exposed by HttpRequest?
I'm guessing this is just a matter of implementing the wrappers' methods.
Thanks

@circlespainter
Copy link
Member

Hi, yes it is a very useful addition indeed. It didn't make for 0.6.0 but it'll be part of the next release.

I'll let you know as soon as there's a snapshot available including it.

@roded
Copy link
Contributor Author

roded commented Feb 13, 2016

Much appreciated.

@roded
Copy link
Contributor Author

roded commented Feb 22, 2016

This is now blocking for me.
Can I assist with this in anyway?

Edit: Erm, nevermind. Not blocking but needed at some point.

@circlespainter
Copy link
Member

Right now we have some higher priorities but we plan to have a look soon at it. Without commitment, it could be as soon as next week.

@roded
Copy link
Contributor Author

roded commented Feb 23, 2016

No worries, I jumped the gun there..
Thanks.

circlespainter pushed a commit that referenced this issue Mar 9, 2016
@circlespainter
Copy link
Member

A new 0.7.0-SNAPSHOT should now be available on SonaType with a new String HttpRequest::getSourceAddress() WebActors API implemented in all backends (servlet through getRemoteAddr, Undertow through getSourceAddress and Netty through the channel's getRemoteAddress) but without proxy-related header inspection (because this might not be what the caller wants). Let me know if this works for you and if you have any suggestions.

@roded
Copy link
Contributor Author

roded commented Mar 11, 2016

Much obliged. Works fine (tried it for Undertow).
As for suggestions, as the client code using HttpRequest has no knowledge of the underlying InetSocketAddress (when working w/ Netty or Undertow), maybe it would be better to expose 3 methods instead of the one: getAddress()/getHost()/getPort(). Or rather, use InetSocketAddress's getHostAddress() instead of toString() which has a special formatting: "host/ip:port".
For your consideration.

@circlespainter
Copy link
Member

No problem, the API was lacking that information indeed.

Yes I was pondering the same but I had missed getRemoteHost / getRemotePort in the servlet API so I ended up exposing the unparsed address. Thanks for the suggestion, I'll think again about it.

@circlespainter
Copy link
Member

Exposing String getSourceHost() (using either InetSocketAddress::getHostString() or HttpServletRequest::getRemoteHost()) and int getSourcePort() (using either InetSocketAddress::getHostPort() or HttpServletRequest::getRemotePort()). Undertow eposes the InetSocketAddress and even in Netty-based Web Actors the SocketAddress willl always actually be InetSocketAddress (although there's a check).

@roded
Copy link
Contributor Author

roded commented Mar 16, 2016

Cool.
Is there a plan to install the latest snapshot on sonatype anytime soon?

@pron
Copy link
Contributor

pron commented Mar 16, 2016

We'll do it tomorrow.

@circlespainter
Copy link
Member

A new snapshot should be available on SonaType.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants