You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2017/05/24 07:39:54 UTC
[1/2] httpcomponents-client git commit: [HTTPCORE-466] Round out the
SslContextBuilder by adding missing APIs.
Repository: httpcomponents-client
Updated Branches:
refs/heads/4.6.x 5ca2eda57 -> aa4817707
[HTTPCORE-466] Round out the SslContextBuilder by adding missing APIs.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/0b91f9ed
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/0b91f9ed
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/0b91f9ed
Branch: refs/heads/4.6.x
Commit: 0b91f9ed0221494e6a0541cfb69889a5c62c7c1d
Parents: 9aff64d
Author: Gary Gregory <gg...@apache.org>
Authored: Wed May 24 00:38:49 2017 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Wed May 24 00:38:49 2017 -0700
----------------------------------------------------------------------
RELEASE_NOTES.txt | 3 ++
.../apache/http/client/utils/URIBuilder.java | 23 +++++++++++++++
.../org/apache/http/client/utils/URIUtils.java | 2 +-
.../http/client/utils/TestURIBuilder.java | 31 +++++++++++++++++++-
4 files changed, 57 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/0b91f9ed/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 8b4a804..0ec2acf 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -39,6 +39,9 @@ Change log:
* [HTTPCLIENT-1828] HttpDelete, HttpGet, HttpHead do not extend HttpEntityEnclosingRequestBase.
Contributed by Saravanakumar Selvaraj <saravanakumar dot java at gmail dot com> and Gary Gregory <ggregory at apache.org>
+* [HTTPCORE-466] Round out the SslContextBuilder by adding missing APIs.
+ Contributed by Gary Gregory <ggregory at apache.org>
+
Release 4.5.3
-------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/0b91f9ed/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
index 91f198c..5d9d897 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
@@ -26,8 +26,10 @@
*/
package org.apache.http.client.utils;
+import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Iterator;
@@ -46,6 +48,15 @@ import org.apache.http.util.TextUtils;
*/
public class URIBuilder {
+ /**
+ * Creates a new builder for the host {@link InetAddress#getLocalHost()}.
+ *
+ * @since 4.6
+ */
+ public static URIBuilder localhost() throws UnknownHostException {
+ return new URIBuilder().setHost(InetAddress.getLocalHost());
+ }
+
private String scheme;
private String encodedSchemeSpecificPart;
private String encodedAuthority;
@@ -248,6 +259,18 @@ public class URIBuilder {
/**
* Sets URI host.
+ *
+ * @since 4.6
+ */
+ public URIBuilder setHost(final InetAddress host) {
+ this.host = host.getHostAddress();
+ this.encodedSchemeSpecificPart = null;
+ this.encodedAuthority = null;
+ return this;
+ }
+
+ /**
+ * Sets URI host.
*/
public URIBuilder setHost(final String host) {
this.host = host;
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/0b91f9ed/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
index 02f8c1a..2ab4b58 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
@@ -141,7 +141,7 @@ public class URIUtils {
uribuilder.setPort(target.getPort());
} else {
uribuilder.setScheme(null);
- uribuilder.setHost(null);
+ uribuilder.setHost((String) null);
uribuilder.setPort(-1);
}
if (dropFragment) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/0b91f9ed/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java b/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
index 8bca89e..5095d39 100644
--- a/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
+++ b/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
@@ -26,6 +26,7 @@
*/
package org.apache.http.client.utils;
+import java.net.InetAddress;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.Charset;
@@ -51,7 +52,7 @@ public class TestURIBuilder {
@Test
public void testMutationToRelativeUri() throws Exception {
final URI uri = new URI("http://stuff@localhost:80/stuff?param=stuff#fragment");
- final URIBuilder uribuilder = new URIBuilder(uri).setHost(null);
+ final URIBuilder uribuilder = new URIBuilder(uri).setHost((String) null);
final URI result = uribuilder.build();
Assert.assertEquals(new URI("http:///stuff?param=stuff#fragment"), result);
}
@@ -211,6 +212,34 @@ public class TestURIBuilder {
}
@Test
+ public void testLocalhost() throws Exception {
+ // Check that the URI generated by URI builder agrees with that generated by using URI directly
+ final String scheme="https";
+ final InetAddress host=InetAddress.getLocalHost();
+ final String specials="/abcd!$&*()_-+.,=:;'~@[]?<>|#^%\"{}\\\u00a3`\u00ac\u00a6xyz"; // N.B. excludes space
+ final URI uri = new URI(scheme, specials, host.getHostAddress(), 80, specials, specials, specials);
+
+ final URI bld = URIBuilder.localhost()
+ .setScheme(scheme)
+ .setUserInfo(specials)
+ .setPath(specials)
+ .setCustomQuery(specials)
+ .setFragment(specials)
+ .build();
+
+ Assert.assertEquals(uri.getHost(), bld.getHost());
+
+ Assert.assertEquals(uri.getUserInfo(), bld.getUserInfo());
+
+ Assert.assertEquals(uri.getPath(), bld.getPath());
+
+ Assert.assertEquals(uri.getQuery(), bld.getQuery());
+
+ Assert.assertEquals(uri.getFragment(), bld.getFragment());
+
+ }
+
+ @Test
public void testAgainstURIEncoded() throws Exception {
// Check that the encoded URI generated by URI builder agrees with that generated by using URI directly
final String scheme="https";
[2/2] httpcomponents-client git commit: Merge branch '4.6.x' of
https://git-wip-us.apache.org/repos/asf/httpcomponents-client.git into 4.6.x
Posted by gg...@apache.org.
Merge branch '4.6.x' of https://git-wip-us.apache.org/repos/asf/httpcomponents-client.git into 4.6.x
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/aa481770
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/aa481770
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/aa481770
Branch: refs/heads/4.6.x
Commit: aa48177074a8b3c49d488cad32375bb0eae5ddaa
Parents: 0b91f9e 5ca2eda
Author: Gary Gregory <gg...@apache.org>
Authored: Wed May 24 00:38:59 2017 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Wed May 24 00:38:59 2017 -0700
----------------------------------------------------------------------
----------------------------------------------------------------------