Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

Access client port and IP address from HttpRequestContext #745

Open
glassfishrobot opened this issue Feb 17, 2010 · 6 comments
Open

Access client port and IP address from HttpRequestContext #745

glassfishrobot opened this issue Feb 17, 2010 · 6 comments

Comments

@glassfishrobot
Copy link

Currently the only way to obtain the client IP address and port is by injecting
HttpServletRequest.

We need to support a method on HttpRequestContext implementations of which can
defer to Servlet or say the low-level Grizzly API.

Low-level Grizzly request has:

request.remoteAddr().toString();
request.getRemotePort();

Environment

Operating System: All
Platform: Macintosh

@glassfishrobot
Copy link
Author

Reported by [email protected]

@glassfishrobot
Copy link
Author

[email protected] said:
Clarification use:

GrizzlyRequest.getRemoteAddr()

@glassfishrobot
Copy link
Author

spektom said:
For a while, I'm using this hack to get the remote IP information: http://stackoverflow.com/a/18378248/398309

@glassfishrobot
Copy link
Author

mikaelstaldal said:
In the context of JAX-RS 2 and Jersey 2, It would make sense to add a method for this to javax.ws.rs.core.Request. Perhaps something for JAX-RS 2.1?

In the meantime, it can be added to org.glassfish.jersey.server.ContainerRequest

@glassfishrobot
Copy link
Author

mpierce said:
For resources, it's possible to work around this by injecting HttpServletRequest or equivalent. However, I need to access the IP inside an event listener. Any thoughts on what workarounds are feasible there?

@glassfishrobot
Copy link
Author

This issue was imported from java.net JIRA JERSEY-473

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

No branches or pull requests

2 participants