summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.apache/src
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2018-11-19 16:00:30 -0800
committerMatthias Sohn <matthias.sohn@sap.com>2018-11-26 03:07:58 -0500
commit3f745e40a131fee439119e2c93d750688a4e47e6 (patch)
tree50940d595c1c7d0f18030a2792ea03628fe7661c /org.eclipse.jgit.http.apache/src
parentf974c9c790dc383b425e9f0ef047251e79354bb7 (diff)
downloadjgit-3f745e40a131fee439119e2c93d750688a4e47e6.tar.gz
jgit-3f745e40a131fee439119e2c93d750688a4e47e6.zip
Add a method to get all values of HTTP header defined as list
According to RFC 2616 [1] header field names are case insensitive. Header fields defined as a comma separated list can have multiple header fields with the same field name. Add a method to HttpConnection which retrieves all values with a given header field name with the field name compared case insensitive. [1] https://tools.ietf.org/html/rfc2616#section-4.2" Change-Id: I7f601b21cda99e84f43f866c7c7cb4cb0e3cf5c3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.http.apache/src')
-rw-r--r--org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java
index 77c5dc0f3e..4ac81a54df 100644
--- a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java
+++ b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java
@@ -58,10 +58,13 @@ import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
@@ -90,6 +93,7 @@ import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.transport.http.HttpConnection;
import org.eclipse.jgit.transport.http.apache.internal.HttpApacheText;
import org.eclipse.jgit.util.TemporaryBuffer;
@@ -347,11 +351,17 @@ public class HttpClientConnection implements HttpConnection {
// will return only the first field
/** {@inheritDoc} */
@Override
- public String getHeaderField(String name) {
+ public String getHeaderField(@NonNull String name) {
Header header = resp.getFirstHeader(name);
return (header == null) ? null : header.getValue();
}
+ @Override
+ public List<String> getHeaderFields(@NonNull String name) {
+ return Collections.unmodifiableList(Arrays.asList(resp.getHeaders(name))
+ .stream().map(Header::getValue).collect(Collectors.toList()));
+ }
+
/** {@inheritDoc} */
@Override
public int getContentLength() {