On Sun, 2011-09-04 at 06:24 -0700, angelogeminiani wrote:
> 
> 
> olegk wrote:
> > 
> > On Fri, 2011-09-02 at 08:22 -0700, angelogeminiani wrote:
> >> Hi,
> >> I'm writing an HTTP server and I need client IP.
> >> I'm using httpcore 4.1.3.
> >> In Servlets it's easy: request.getRemoteAddr().
> >> Is there similar method in HttpRequest, or a way to retrieve client IP
> >> from
> >> server?
> >> 
> > 
> > You can cast any instance of the HttpConnection interface to
> > HttpInetConnection in order to get access to IP address of its
> > endpoints:  
> > 
> > http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/HttpInetConnection.html
> >   
> > 
> > Oleg
> > 
> 
> Thank you Olegk for your help.
> I'm writing a server starting from 
> http://hc.apache.org/httpcomponents-core-ga/httpcore-nio/examples/org/apache/http/examples/nio/NHttpServer.java
> and need Client IP in file handler.
> Where can I get a HttpConnection instance?
> Is there any in HttpRequest?
> I need IP of client in HttpFileHandler.
> Thak you.
> 

You can obtain the underlying connection from the HTTP context using
ExecutionContext#HTTP_CONNECTION as a key.

Hope this helps.

Oleg 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to