Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-656

IP address of the server of a HttpConnection

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0 Alpha 1
    • HttpClient (classic)
    • None

    Description

      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();
      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            arminha Armin Häberling
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: