You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "cstamas (via GitHub)" <gi...@apache.org> on 2026/05/13 13:17:30 UTC

[PR] Feat: Reuse same RemoteRepository to HTTP URI creation logic [maven-resolver]

cstamas opened a new pull request, #1878:
URL: https://github.com/apache/maven-resolver/pull/1878

   All HTTP remote repositories have pretty much same or similar expectations regardind base URI of a HTTP remote repository.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: Reuse same RemoteRepository to HTTP URI creation logic [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #1878:
URL: https://github.com/apache/maven-resolver/pull/1878#discussion_r3234803090


##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/connector/transport/http/HttpTransporterUtils.java:
##########
@@ -299,4 +301,30 @@ public static Optional<InetAddress> getHttpLocalAddress(
         }
         return Optional.empty();
     }
+
+    /**
+     * Shared code to create "base {@link URI}" for most common HTTP remote repositories and all HTTP transports.
+     *
+     * @since 2.0.18
+     */
+    public static URI getBaseUri(RemoteRepository repository) throws URISyntaxException {
+        URI uri = new URI(repository.getUrl()).parseServerAuthority();
+        if (uri.isOpaque()) {
+            throw new URISyntaxException(repository.getUrl(), "URL must not be opaque");
+        }
+        if (uri.getRawFragment() != null || uri.getRawQuery() != null) {
+            throw new URISyntaxException(repository.getUrl(), "URL must not have fragment or query");
+        }
+        String path = uri.getRawPath();
+        if (path == null) {
+            path = "/";
+        }
+        if (!path.startsWith("/")) {

Review Comment:
   Yes, the "empty" case is what we want



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: Reuse same RemoteRepository to HTTP URI creation logic [maven-resolver]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #1878:
URL: https://github.com/apache/maven-resolver/pull/1878#discussion_r3234631814


##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/connector/transport/http/HttpTransporterUtils.java:
##########
@@ -299,4 +301,30 @@ public static Optional<InetAddress> getHttpLocalAddress(
         }
         return Optional.empty();
     }
+
+    /**
+     * Shared code to create "base {@link URI}" for most common HTTP remote repositories and all HTTP transports.
+     *
+     * @since 2.0.18
+     */
+    public static URI getBaseUri(RemoteRepository repository) throws URISyntaxException {
+        URI uri = new URI(repository.getUrl()).parseServerAuthority();
+        if (uri.isOpaque()) {
+            throw new URISyntaxException(repository.getUrl(), "URL must not be opaque");
+        }
+        if (uri.getRawFragment() != null || uri.getRawQuery() != null) {
+            throw new URISyntaxException(repository.getUrl(), "URL must not have fragment or query");
+        }
+        String path = uri.getRawPath();
+        if (path == null) {
+            path = "/";
+        }
+        if (!path.startsWith("/")) {

Review Comment:
   I don't think this can ever happen! Path is according to https://www.rfc-editor.org/rfc/rfc3986#section-3.3 either empty or starts with "/".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: Reuse same RemoteRepository to HTTP URI creation logic [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas merged PR #1878:
URL: https://github.com/apache/maven-resolver/pull/1878


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat: Reuse same RemoteRepository to HTTP URI creation logic [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #1878:
URL: https://github.com/apache/maven-resolver/pull/1878#discussion_r3234803090


##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/connector/transport/http/HttpTransporterUtils.java:
##########
@@ -299,4 +301,30 @@ public static Optional<InetAddress> getHttpLocalAddress(
         }
         return Optional.empty();
     }
+
+    /**
+     * Shared code to create "base {@link URI}" for most common HTTP remote repositories and all HTTP transports.
+     *
+     * @since 2.0.18
+     */
+    public static URI getBaseUri(RemoteRepository repository) throws URISyntaxException {
+        URI uri = new URI(repository.getUrl()).parseServerAuthority();
+        if (uri.isOpaque()) {
+            throw new URISyntaxException(repository.getUrl(), "URL must not be opaque");
+        }
+        if (uri.getRawFragment() != null || uri.getRawQuery() != null) {
+            throw new URISyntaxException(repository.getUrl(), "URL must not have fragment or query");
+        }
+        String path = uri.getRawPath();
+        if (path == null) {
+            path = "/";
+        }
+        if (!path.startsWith("/")) {

Review Comment:
   Yes, the "empty" case is what we want, or maybe not (is "empty" == null?)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org