Skip to content

Commit

Permalink
[MRESOLVER-595] Expose follow and max redirects for Jetty client (#549)
Browse files Browse the repository at this point in the history
Expose config for Jetty client redirect handling.

---

https://issues.apache.org/jira/browse/MRESOLVER-595
  • Loading branch information
cstamas authored Aug 2, 2024
1 parent 55343dc commit d6fb916
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,14 @@ public X509Certificate[] getAcceptedIssuers() {

HttpClient httpClient = new HttpClient(transport);
httpClient.setConnectTimeout(connectTimeout);
httpClient.setFollowRedirects(true);
httpClient.setMaxRedirects(2);
httpClient.setFollowRedirects(ConfigUtils.getBoolean(
session,
JettyTransporterConfigurationKeys.DEFAULT_FOLLOW_REDIRECTS,
JettyTransporterConfigurationKeys.CONFIG_PROP_FOLLOW_REDIRECTS));
httpClient.setMaxRedirects(ConfigUtils.getInteger(
session,
JettyTransporterConfigurationKeys.DEFAULT_MAX_REDIRECTS,
JettyTransporterConfigurationKeys.CONFIG_PROP_MAX_REDIRECTS));

httpClient.setUserAgentField(null); // we manage it

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.eclipse.aether.transport.jetty;

import org.eclipse.aether.ConfigurationProperties;
import org.eclipse.aether.RepositorySystemSession;

/**
* Configuration for Jetty Transport.
*
* @since 2.0.1
*/
public final class JettyTransporterConfigurationKeys {
private JettyTransporterConfigurationKeys() {}

static final String CONFIG_PROPS_PREFIX =
ConfigurationProperties.PREFIX_TRANSPORT + JettyTransporterFactory.NAME + ".";

/**
* If enabled, Jetty client will follow HTTP redirects.
*
* @configurationSource {@link RepositorySystemSession#getConfigProperties()}
* @configurationType {@link Boolean}
* @configurationDefaultValue {@link #DEFAULT_FOLLOW_REDIRECTS}
* @configurationRepoIdSuffix Yes
*/
public static final String CONFIG_PROP_FOLLOW_REDIRECTS = CONFIG_PROPS_PREFIX + "followRedirects";

public static final boolean DEFAULT_FOLLOW_REDIRECTS = true;

/**
* The max redirect count to follow.
*
* @configurationSource {@link RepositorySystemSession#getConfigProperties()}
* @configurationType {@link Integer}
* @configurationDefaultValue {@link #DEFAULT_MAX_REDIRECTS}
* @configurationRepoIdSuffix Yes
*/
public static final String CONFIG_PROP_MAX_REDIRECTS = CONFIG_PROPS_PREFIX + "maxRedirects";

public static final int DEFAULT_MAX_REDIRECTS = 5;
}
24 changes: 13 additions & 11 deletions src/site/markdown/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,19 @@ under the License.
| 103. | `"aether.transport.https.securityMode"` | `String` | The mode that sets HTTPS transport "security mode": to ignore any SSL errors (certificate validity checks, hostname verification). The default value is . | `"default"` | 1.9.6 | Yes | Session Configuration |
| 104. | `"aether.transport.jdk.httpVersion"` | `String` | Use string representation of HttpClient version enum "HTTP_2" or "HTTP_1_1" to set default HTTP protocol to use. | `"HTTP_2"` | 2.0.0 | Yes | Session Configuration |
| 105. | `"aether.transport.jdk.maxConcurrentRequests"` | `Integer` | The hard limit of maximum concurrent requests JDK transport can do. This is a workaround for the fact, that in HTTP/2 mode, JDK HttpClient initializes this value to Integer.MAX_VALUE (!) and lowers it on first response from the remote server (but it may be too late). See JDK bug <a href="https://bugs.openjdk.org/browse/JDK-8225647">JDK-8225647</a> for details. | `100` | 2.0.0 | Yes | Session Configuration |
| 106. | `"aether.transport.wagon.config"` | `Object` | The configuration to use for the Wagon provider. | - | | Yes | Session Configuration |
| 107. | `"aether.transport.wagon.perms.dirMode"` | `String` | Octal numerical notation of permissions to set for newly created directories. Only considered by certain Wagon providers. | - | | Yes | Session Configuration |
| 108. | `"aether.transport.wagon.perms.fileMode"` | `String` | Octal numerical notation of permissions to set for newly created files. Only considered by certain Wagon providers. | - | | Yes | Session Configuration |
| 109. | `"aether.transport.wagon.perms.group"` | `String` | Group which should own newly created directories/files. Only considered by certain Wagon providers. | - | | Yes | Session Configuration |
| 110. | `"aether.trustedChecksumsSource.sparseDirectory"` | `Boolean` | Is checksum source enabled? | `false` | 1.9.0 | No | Session Configuration |
| 111. | `"aether.trustedChecksumsSource.sparseDirectory.basedir"` | `String` | The basedir where checksums are. If relative, is resolved from local repository root. | `".checksums"` | 1.9.0 | No | Session Configuration |
| 112. | `"aether.trustedChecksumsSource.sparseDirectory.originAware"` | `Boolean` | Is source origin aware? | `true` | 1.9.0 | No | Session Configuration |
| 113. | `"aether.trustedChecksumsSource.summaryFile"` | `Boolean` | Is checksum source enabled? | `false` | 1.9.0 | No | Session Configuration |
| 114. | `"aether.trustedChecksumsSource.summaryFile.basedir"` | `String` | The basedir where checksums are. If relative, is resolved from local repository root. | `".checksums"` | 1.9.0 | No | Session Configuration |
| 115. | `"aether.trustedChecksumsSource.summaryFile.originAware"` | `Boolean` | Is source origin aware? | `true` | 1.9.0 | No | Session Configuration |
| 116. | `"aether.updateCheckManager.sessionState"` | `String` | Manages the session state, i.e. influences if the same download requests to artifacts/metadata will happen multiple times within the same RepositorySystemSession. If "enabled" will enable the session state. If "bypass" will enable bypassing (i.e. store all artifact ids/metadata ids which have been updates but not evaluating those). All other values lead to disabling the session state completely. | `"enabled"` | | No | Session Configuration |
| 106. | `"aether.transport.jetty.followRedirects"` | `Boolean` | If enabled, Jetty client will follow HTTP redirects. | `true` | 2.0.1 | Yes | Session Configuration |
| 107. | `"aether.transport.jetty.maxRedirects"` | `Integer` | The max redirect count to follow. | `5` | 2.0.1 | Yes | Session Configuration |
| 108. | `"aether.transport.wagon.config"` | `Object` | The configuration to use for the Wagon provider. | - | | Yes | Session Configuration |
| 109. | `"aether.transport.wagon.perms.dirMode"` | `String` | Octal numerical notation of permissions to set for newly created directories. Only considered by certain Wagon providers. | - | | Yes | Session Configuration |
| 110. | `"aether.transport.wagon.perms.fileMode"` | `String` | Octal numerical notation of permissions to set for newly created files. Only considered by certain Wagon providers. | - | | Yes | Session Configuration |
| 111. | `"aether.transport.wagon.perms.group"` | `String` | Group which should own newly created directories/files. Only considered by certain Wagon providers. | - | | Yes | Session Configuration |
| 112. | `"aether.trustedChecksumsSource.sparseDirectory"` | `Boolean` | Is checksum source enabled? | `false` | 1.9.0 | No | Session Configuration |
| 113. | `"aether.trustedChecksumsSource.sparseDirectory.basedir"` | `String` | The basedir where checksums are. If relative, is resolved from local repository root. | `".checksums"` | 1.9.0 | No | Session Configuration |
| 114. | `"aether.trustedChecksumsSource.sparseDirectory.originAware"` | `Boolean` | Is source origin aware? | `true` | 1.9.0 | No | Session Configuration |
| 115. | `"aether.trustedChecksumsSource.summaryFile"` | `Boolean` | Is checksum source enabled? | `false` | 1.9.0 | No | Session Configuration |
| 116. | `"aether.trustedChecksumsSource.summaryFile.basedir"` | `String` | The basedir where checksums are. If relative, is resolved from local repository root. | `".checksums"` | 1.9.0 | No | Session Configuration |
| 117. | `"aether.trustedChecksumsSource.summaryFile.originAware"` | `Boolean` | Is source origin aware? | `true` | 1.9.0 | No | Session Configuration |
| 118. | `"aether.updateCheckManager.sessionState"` | `String` | Manages the session state, i.e. influences if the same download requests to artifacts/metadata will happen multiple times within the same RepositorySystemSession. If "enabled" will enable the session state. If "bypass" will enable bypassing (i.e. store all artifact ids/metadata ids which have been updates but not evaluating those). All other values lead to disabling the session state completely. | `"enabled"` | | No | Session Configuration |


All properties which have `yes` in the column `Supports Repo ID Suffix` can be optionally configured specifically for a repository id. In that case the configuration property needs to be suffixed with a period followed by the repository id of the repository to configure, e.g. `aether.connector.http.headers.central` for repository with id `central`.
Expand Down

0 comments on commit d6fb916

Please # to comment.