You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2021/12/04 13:00:18 UTC

[jena] branch main updated: JENA-2203: Set default redirect to ALWAYS

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

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git


The following commit(s) were added to refs/heads/main by this push:
     new d0c467a  JENA-2203: Set default redirect to ALWAYS
     new b7f7994  Merge pull request #1122 from afs/jena2203-redirect
d0c467a is described below

commit d0c467a11c164dcc4170930805c018e6ded1f533
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Fri Dec 3 12:27:51 2021 +0000

    JENA-2203: Set default redirect to ALWAYS
---
 jena-arq/src/main/java/org/apache/jena/http/HttpEnv.java              | 4 +++-
 .../src/main/java/arq/examples/auth/ExAuth01_RDFConnectionPW.java     | 1 +
 .../src/main/java/arq/examples/auth/ExAuth03_UpdateExecutionPW.java   | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/jena-arq/src/main/java/org/apache/jena/http/HttpEnv.java b/jena-arq/src/main/java/org/apache/jena/http/HttpEnv.java
index a3c6f55..d2147da 100644
--- a/jena-arq/src/main/java/org/apache/jena/http/HttpEnv.java
+++ b/jena-arq/src/main/java/org/apache/jena/http/HttpEnv.java
@@ -65,7 +65,9 @@ public class HttpEnv {
                 // By default, the client has polling and connection-caching.
                 // Version HTTP/2 is the default, negotiating up from HTTP 1.1.
                 .connectTimeout(Duration.ofSeconds(10))
-                .followRedirects(Redirect.NORMAL)
+                // Redirect.NORMAL - this does not follow https to http 3xx.
+                // (Dec 2021) http://purl.org first switches to https://purl.org, then will redirect to an http: URL.
+                .followRedirects(Redirect.ALWAYS)
                 //.sslContext
                 //.sslParameters
                 //.proxy
diff --git a/jena-examples/src/main/java/arq/examples/auth/ExAuth01_RDFConnectionPW.java b/jena-examples/src/main/java/arq/examples/auth/ExAuth01_RDFConnectionPW.java
index a345a61..8c950d1 100644
--- a/jena-examples/src/main/java/arq/examples/auth/ExAuth01_RDFConnectionPW.java
+++ b/jena-examples/src/main/java/arq/examples/auth/ExAuth01_RDFConnectionPW.java
@@ -83,6 +83,7 @@ public class ExAuth01_RDFConnectionPW {
         Authenticator authenticator = AuthLib.authenticator("u", "p");
         HttpClient httpClient = HttpClient.newBuilder()
                 .connectTimeout(Duration.ofSeconds(10))
+                //.followRedirects -- the default is Redirect.NEVER
                 .authenticator(authenticator)
                 .build();
         try ( RDFConnection conn = RDFConnectionRemote.service(dataURL)
diff --git a/jena-examples/src/main/java/arq/examples/auth/ExAuth03_UpdateExecutionPW.java b/jena-examples/src/main/java/arq/examples/auth/ExAuth03_UpdateExecutionPW.java
index 6ad4c31..e1dc1fc 100644
--- a/jena-examples/src/main/java/arq/examples/auth/ExAuth03_UpdateExecutionPW.java
+++ b/jena-examples/src/main/java/arq/examples/auth/ExAuth03_UpdateExecutionPW.java
@@ -67,6 +67,7 @@ public class ExAuth03_UpdateExecutionPW {
         System.out.println("HttpClient + UpdateExecutionHTTP");
         Authenticator authenticator = AuthLib.authenticator("u", "p");
         HttpClient httpClient = HttpClient.newBuilder()
+                //.followRedirect
                 .connectTimeout(Duration.ofSeconds(10))
                 .authenticator(authenticator)
                 .build();