001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.eclipse.aether.transport.url;
020
021import org.eclipse.aether.ConfigurationProperties;
022import org.eclipse.aether.RepositorySystemSession;
023
024/**
025 * Configuration for URL Transport.
026 *
027 * @since 2.0.21
028 */
029public final class UrlTransporterConfigurationKeys {
030    private UrlTransporterConfigurationKeys() {}
031
032    static final String CONFIG_PROPS_PREFIX =
033            ConfigurationProperties.PREFIX_TRANSPORT + UrlTransporterFactory.NAME + ".";
034
035    /**
036     * The redirect mode of the transport. Accepted values are {@code NONE}, when any redirect response from server
037     * result in transport error, {@code SAME_AUTHORITY} when transport follow redirects only happening within same
038     * URI authority (same server), and {@code ANY} when redirects are followed everywhere.
039     *
040     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
041     * @configurationType {@link String}
042     * @configurationDefaultValue {@link #DEFAULT_REDIRECT_MODE}
043     * @configurationRepoIdSuffix Yes
044     */
045    public static final String CONFIG_PROP_REDIRECT_MODE = CONFIG_PROPS_PREFIX + "redirectMode";
046
047    public static final String DEFAULT_REDIRECT_MODE = "ANY";
048
049    /**
050     * Maximum count of redirects that transport follows within one transaction.
051     *
052     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
053     * @configurationType {@link Integer}
054     * @configurationDefaultValue {@link #DEFAULT_MAX_REDIRECT_COUNT}
055     * @configurationRepoIdSuffix Yes
056     */
057    public static final String CONFIG_PROP_MAX_REDIRECT_COUNT = CONFIG_PROPS_PREFIX + "maxRedirectCount";
058
059    public static final int DEFAULT_MAX_REDIRECT_COUNT = 5;
060
061    /**
062     * Whether protocol downgrade (HTTPS -> HTTP) is allowed during redirect following.
063     *
064     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
065     * @configurationType {@link java.lang.Boolean}
066     * @configurationDefaultValue {@link #DEFAULT_REDIRECT_ALLOW_DOWNGRADE}
067     * @configurationRepoIdSuffix Yes
068     */
069    public static final String CONFIG_PROP_REDIRECT_ALLOW_DOWNGRADE = CONFIG_PROPS_PREFIX + "redirectAllowDowngrade";
070
071    public static final boolean DEFAULT_REDIRECT_ALLOW_DOWNGRADE = false;
072
073    /**
074     * Whether this transport should close the HTTP connection at the end of each transaction, effectively
075     * disabling persistent connections (keep-alive). This configuration affects only this transport.
076     * Important to note, that globally, on JVM-wide level persistent connections are controlled by
077     * <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html">{@code http.keepAlive}</a>
078     * Java system property, that is {@code true} by default. If this system property is set to {@code false}, this
079     * transport cannot use persistent connections either.
080     *
081     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
082     * @configurationType {@link java.lang.Boolean}
083     * @configurationDefaultValue {@link #DEFAULT_CLOSE_CONNECTION}
084     * @configurationRepoIdSuffix Yes
085     */
086    public static final String CONFIG_PROP_CLOSE_CONNECTION = CONFIG_PROPS_PREFIX + "closeConnection";
087
088    public static final boolean DEFAULT_CLOSE_CONNECTION = false;
089}