aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-05-02 13:31:30 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2023-05-03 02:40:41 +0200
commit3d90c4a433f889a755be7cccb639ae16d95fe9a1 (patch)
treedea362d2e6ed1c9b4c4477358377075d6dcdb2f8
parent731dfd4c5eb6f88b98e983b9b0551b3562a0c46c (diff)
downloadjgit-3d90c4a433f889a755be7cccb639ae16d95fe9a1.tar.gz
jgit-3d90c4a433f889a755be7cccb639ae16d95fe9a1.zip
Add TransportHttp#getAdditionalHeaders
to enable inspecting which additional HTTP headers have been set on the transport. Change-Id: I0771be9cb7c837de7c203b7f044109b9b2a7d7ad
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java11
2 files changed, 20 insertions, 1 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
index 0ea15d39e5..cda2b32529 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
@@ -18,6 +18,7 @@ import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
@@ -84,8 +85,15 @@ public class SetAdditionalHeadersTest extends AllFactoriesHttpTestCase {
HashMap<String, String> headers = new HashMap<>();
headers.put("Cookie", "someTokenValue=23gBog34");
headers.put("AnotherKey", "someValue");
- ((TransportHttp) t).setAdditionalHeaders(headers);
+
+ @SuppressWarnings("resource")
+ TransportHttp th = (TransportHttp) t;
+ th.setAdditionalHeaders(headers);
t.openFetch();
+
+ Map<String, String> h = th.getAdditionalHeaders();
+ assertEquals("someTokenValue=23gBog34", h.get("Cookie"));
+ assertEquals("someValue", h.get("AnotherKey"));
}
List<AccessEvent> requests = getRequests();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
index 405373a0f9..df034bdc8b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
@@ -588,6 +588,17 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
this.headers = headers;
}
+ /**
+ * Get additional headers on the HTTP connection
+ *
+ * @return unmodifiable map of additional name:values that are set as
+ * headers on the HTTP connection
+ * @since 6.6
+ */
+ public Map<String, String> getAdditionalHeaders() {
+ return Collections.unmodifiableMap(headers);
+ }
+
private NoRemoteRepositoryException createNotFoundException(URIish u,
URL url, String msg) {
String text;