aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2022-06-15 16:31:38 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2022-06-15 16:31:38 +0200
commitd961bb65024815996d82094cacaba811bf5eab85 (patch)
tree61a1ab2d2b28a8c263172f3bfc3504c8fed6168d /org.eclipse.jgit/src/org/eclipse/jgit/util
parenta96645a5f3e97b5c291ff51b8a4d1654052266b4 (diff)
parentdb074a1352bc136584fd80e7d301ae60ffff5d59 (diff)
downloadjgit-d961bb65024815996d82094cacaba811bf5eab85.tar.gz
jgit-d961bb65024815996d82094cacaba811bf5eab85.zip
Merge branch 'stable-5.13' into stable-6.0
* stable-5.13: Prepare 5.13.2-SNAPSHOT builds JGit v5.13.1.202206130422-r AmazonS3: Add support for AWS API signature version 4 Change-Id: Ibd663a1d874d1aac274abc3dd44354fd99f64c39
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
index 23a73faf8c..663a3449e1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
@@ -186,6 +186,33 @@ public class HttpSupport {
}
/**
+ * Translates the provided URL into application/x-www-form-urlencoded
+ * format.
+ *
+ * @param url
+ * The URL to translate.
+ * @param keepPathSlash
+ * Whether or not to keep "/" in the URL (i.e. don't translate
+ * them to "%2F").
+ *
+ * @return The translated URL.
+ * @since 5.13
+ */
+ public static String urlEncode(String url, boolean keepPathSlash) {
+ String encoded;
+ try {
+ encoded = URLEncoder.encode(url, UTF_8.name());
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8,
+ e);
+ }
+ if (keepPathSlash) {
+ encoded = encoded.replace("%2F", "/"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return encoded;
+ }
+
+ /**
* Get the HTTP response code from the request.
* <p>
* Roughly the same as <code>c.getResponseCode()</code> but the