hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ortwin Glück (JIRA) <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-656) IP address of the server of a HttpConnection
Date Tue, 05 Jun 2007 23:00:34 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12501733
] 

Ortwin Glück commented on HTTPCLIENT-656:
-----------------------------------------

Armin,

The feature request suggests that you don't know or forget to what server you have established
a connection. I don't see a real-world use case for that. Read: you should know where you
are connecting!

Ortwin

> IP address of the server of a HttpConnection
> --------------------------------------------
>
>                 Key: HTTPCLIENT-656
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-656
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: HttpConn
>            Reporter: Armin Häberling
>             Fix For: 4.0 Alpha 1
>
>
> AFAIK it's not possible to get the IP address of the server of a HttpConnection.
> I propose to add a getServerAddress() method to the HttpConnection class that returns
the IP address of the server, if the connection has been opened.
> And either returns null or throws an Exception if the IP address is not available, i.e.
the connection is not open.
> Below is a workaround for getting the IP address in current versions.
> -----------------------
> package org.apache.commons.httpclient;
> import java.io.IOException;
> import java.net.InetAddress;
> public class InetAddressFetcher {
> 	private HttpConnection hc;
> 	public InetAddressFetcher(HttpConnection hc) {
> 		this.hc = hc;
> 	}
> 	public InetAddress getInetAddress() throws IOException {
> 		if (!hc.isOpen()) {
> 			hc.open();
> 		}
> 		return hc.getSocket().getInetAddress();
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Mime
View raw message