Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333717 - HttpClient can't get local listen address
Summary: HttpClient can't get local listen address
Status: CLOSED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: client (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 7.1.x   Edit
Assignee: Jesse McConnell CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-06 21:32 EST by mickyp CLA
Modified: 2011-01-11 14:58 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mickyp CLA 2011-01-06 21:32:16 EST
Build Identifier: 


On 06/01/2011 03:02, Micky Lee wrote: 
Dear Thomas,
 
Thanks!!
It’s a good idea I never thought to let the remote server response a HttpServletRequest.getRemoteAddr().
 
My application has a function to show the local IP in the UI. And my application will run on Server PC.
In case that there may be many network cards installed in a Server PC. I don’t know to show which local IP in the UI.
My application has another function to monitor remote HTTP server status.
So I try to use Jetty HttpClient to achieve the function and hope it can get the correct local IP when a http connection established.
Therefore I will have the local IP to show in UI, the users, almost MIS, will know my application use which IP to monitor remote HTTP server. 
And this help them to easily tune IPs if they needed.
 
For the reason I may not have the control of remote HTTP server (using Servlets, to response HttpServletRequest.getRemoteAddr()), I still need a method to get local IP after a successful http request connected.
 
Hope this describes the situation I occurred clearly.
 
Thanks in advance.
 
Sincerely,
Micky
 
From: jetty-users-bounces@eclipse.org [mailto:jetty-users-bounces@eclipse.org] On Behalf Of Thomas Becker
Sent: Tuesday, January 04, 2011 7:48 PM
To: JETTY user mailing list
Subject: Re: [jetty-users] How to get listen address after a HttpClient request?
 
Micky, could you please tell us more on how your clients connect to your application? Are you using plain Servlets? Then you will be able to get the client IP address from the HttpServletRequest (http://download.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html) object passed to your servlet's doGet|doPost|service|... method.

HttpServletRequest.getRemoteAddr().

Hope that helps.

On 03/01/2011 10:07, Micky Lee wrote: 
Dear Thomas,
 
 
It’s great to log the request and know the client IP address for me.
 
But what I need is my program need to show this client IP in my application UI.
I have no way to directly get that IP.
 
Thanks in advance.
 
Sincerely,
Micky
 
 
From: jetty-users-bounces@eclipse.org [mailto:jetty-users-bounces@eclipse.org] On Behalf Of Thomas Becker
Sent: Monday, January 03, 2011 3:50 PM
To: JETTY user mailing list
Subject: Re: [jetty-users] How to get listen address after a HttpClient request?
 
Hi Micky,

if I got your request right you want to have a request log, logging each client's request with client ip address and some additional information.

Then this HowTo will help you to enable it:
http://wiki.eclipse.org/Jetty/Howto/Configure_Request_Logs

If you've any further questions or if this is not what you're asking for, don't hesitate to ask the list again.

Cheers,
Thomas

On 03/01/2011 03:33, Micky Lee wrote: 
Dear all,
 
 
I want to get the local listen address of a request of HttpClient.
It means after a successful GET/POST request by using HttpClient, I want to get the connecting local address. (listen address too)
 
I didn’t find any document or API described it.
 
Can anyone help me?
 
Sincerely,
Micky
 
 
 
 


Reproducible: Always
Comment 1 Jesse McConnell CLA 2011-01-11 14:58:37 EST
I added a getLocalAddress() method to the HttpExchange class for you.

it will return the host:port pairing of the local side of the connection used for the running of that exchange.  I have noted in the javadoc that it will return null if that information was not available or if the exchange hasn't been run (which makes sense)

this should be in jetty-7.3 in a couple of weeks

Committed revision 2651.