You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2019/11/14 15:45:52 UTC

[httpcomponents-client] 01/01: HTTPCLIENT-2029: URIBuilder to support parsing of non-UTF8 URIs

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch HTTPCLIENT-2029
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit 332a7ae919d7634feb2485e970173b7fa4c1be0b
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Thu Nov 14 16:43:14 2019 +0100

    HTTPCLIENT-2029: URIBuilder to support parsing of non-UTF8 URIs
---
 .../org/apache/http/client/utils/URIBuilder.java   | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

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 f7b6a92..8838598 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
@@ -79,8 +79,7 @@ public class URIBuilder {
      * @throws URISyntaxException if the input is not a valid URI
      */
     public URIBuilder(final String string) throws URISyntaxException {
-        super();
-        digestURI(new URI(string));
+        this(new URI(string), null);
     }
 
     /**
@@ -88,7 +87,26 @@ public class URIBuilder {
      * @param uri
      */
     public URIBuilder(final URI uri) {
+        this(uri, null);
+    }
+
+    /**
+     * Construct an instance from the string which must be a valid URI.
+     *
+     * @param string a valid URI in string form
+     * @throws URISyntaxException if the input is not a valid URI
+     */
+    public URIBuilder(final String string, final Charset charset) throws URISyntaxException {
+        this(new URI(string), charset);
+    }
+
+    /**
+     * Construct an instance from the provided URI.
+     * @param uri
+     */
+    public URIBuilder(final URI uri, final Charset charset) {
         super();
+        setCharset(charset);
         digestURI(uri);
     }