You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by pbkwee <gi...@git.apache.org> on 2014/08/06 07:09:55 UTC

[GitHub] httpcore pull request: The HttpHost InetAddress constructor will u...

GitHub user pbkwee opened a pull request:

    https://github.com/apache/httpcore/pull/1

    The HttpHost InetAddress constructor will use the InetAddress#getHostNam...

    ...e (rather than InetAddress#getHostAddress) when provided with an InetAddress.
    
    System.out.println(new HttpHost(InetAddress.getByAddress("127.0.0.1", new byte[] {127,0,0,1}), 80, "http"));
    System.out.println(new HttpHost(InetAddress.getByAddress(new byte[] {127,0,0,1}), 80, "http"));
    System.out.println(new HttpHost(InetAddress.getByAddress("somehost", new byte[] {127,0,0,1}), 80, "http"));
    
    Produces:
    http://127.0.0.1:80
    http://localhost:80
    http://somehost:80
    
    This ensures that HttpHost#getHostName reflects the name wish to use (rather than the IP address).  Which can be important, for example with Cookie domains and HTTP Host: headers.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/pbkwee/httpcore 4.3.x

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/httpcore/pull/1.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1
    
----
commit 696baadb8b03428f9e12f24225ecd0ae45118788
Author: peter@rimuhosting.com <pe...@rimuhosting.com>
Date:   2014-08-06T04:55:59Z

    The HttpHost InetAddress constructor will use the InetAddress#getHostName (rather than InetAddress#getHostAddress) when provided with an InetAddress.
    
    System.out.println(new HttpHost(InetAddress.getByAddress("127.0.0.1", new byte[] {127,0,0,1}), 80, "http"));
    System.out.println(new HttpHost(InetAddress.getByAddress(new byte[] {127,0,0,1}), 80, "http"));
    System.out.println(new HttpHost(InetAddress.getByAddress("somehost", new byte[] {127,0,0,1}), 80, "http"));
    
    Produces:
    http://127.0.0.1:80
    http://localhost:80
    http://somehost:80
    
    This ensures that HttpHost#getHostName reflects the name wish to use (rather than the IP address).  Which can be important, for example with Cookie domains and HTTP Host: headers.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] httpcore pull request: The HttpHost InetAddress constructor will u...

Posted by pbkwee <gi...@git.apache.org>.
Github user pbkwee commented on the pull request:

    https://github.com/apache/httpcore/pull/1#issuecomment-51740755
  
    @ok2c ok to pull this?  javadoc updated.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] httpcore pull request: The HttpHost InetAddress constructor will u...

Posted by pbkwee <gi...@git.apache.org>.
Github user pbkwee closed the pull request at:

    https://github.com/apache/httpcore/pull/1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] httpcore pull request: The HttpHost InetAddress constructor will u...

Posted by ok2c <gi...@git.apache.org>.
Github user ok2c commented on a diff in the pull request:

    https://github.com/apache/httpcore/pull/1#discussion_r15877520
  
    --- Diff: httpcore/src/main/java/org/apache/http/HttpHost.java ---
    @@ -262,9 +278,12 @@ public boolean equals(final Object obj) {
             }
             if (obj instanceof HttpHost) {
                 final HttpHost that = (HttpHost) obj;
    --- End diff --
    
    I am fine with adding another constructor, but I would prefer #hashCode and #equals to do a simple value to value comparison instead of comparing some derived values.
    
    Oleg


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] httpcore pull request: The HttpHost InetAddress constructor will u...

Posted by pbkwee <gi...@git.apache.org>.
Github user pbkwee commented on a diff in the pull request:

    https://github.com/apache/httpcore/pull/1#discussion_r15904388
  
    --- Diff: httpcore/src/main/java/org/apache/http/HttpHost.java ---
    @@ -262,9 +278,12 @@ public boolean equals(final Object obj) {
             }
             if (obj instanceof HttpHost) {
                 final HttpHost that = (HttpHost) obj;
    --- End diff --
    
    OK.  Updated #equals and #hashCode and committed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] httpcore pull request: The HttpHost InetAddress constructor will u...

Posted by ok2c <gi...@git.apache.org>.
Github user ok2c commented on the pull request:

    https://github.com/apache/httpcore/pull/1#issuecomment-51685989
  
    Committed to SVN trunk.
    
    http://svn.apache.org/r1616939
    
    Oleg


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] httpcore pull request: The HttpHost InetAddress constructor will u...

Posted by ok2c <gi...@git.apache.org>.
Github user ok2c commented on the pull request:

    https://github.com/apache/httpcore/pull/1#issuecomment-51776141
  
    Could you please close this PR and open a new one given this change is completely unrelated to the original issue?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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