aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webdav/src/main
diff options
context:
space:
mode:
authorCiprian Ciubotariu <cheepeero@gmx.net>2016-10-04 17:16:50 +0300
committerCiprian Ciubotariu <cheepeero@gmx.net>2016-10-04 18:12:05 +0300
commitef0f29235d7d5ebecf3f60accf2c76bcb7c8230b (patch)
tree341131e752e91571489f5749e667ce6543980d7b /archiva-modules/archiva-web/archiva-webdav/src/main
parent1fd9c951e19a30f7636f4a924cb9e2bf06af2861 (diff)
downloadarchiva-ef0f29235d7d5ebecf3f60accf2c76bcb7c8230b.tar.gz
archiva-ef0f29235d7d5ebecf3f60accf2c76bcb7c8230b.zip
[MRM-1928] Use applicationUrl setting in HTTP redirects
Make use of webapp application URL setting when constructing the HTTP Location header within redirect responses, which allows clients to follow them when Archiva runs behind HTTP reverse proxies.
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webdav/src/main')
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
index 93547c0d9..d4958b113 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
@@ -47,7 +47,6 @@ import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.policies.ProxyDownloadException;
import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
-import org.apache.archiva.proxy.model.ProxyFetchResult;
import org.apache.archiva.redback.authentication.AuthenticationException;
import org.apache.archiva.redback.authentication.AuthenticationResult;
import org.apache.archiva.redback.authorization.AuthorizationException;
@@ -577,8 +576,7 @@ public class ArchivaDavResourceFactory
String path = e.getPath();
log.debug( "Relocation to {}", path );
- throw new BrowserRedirectException( contextPath + ( StringUtils.startsWith( path, "/" ) ? "" : "/" ) + path,
- e.getRelocationType() );
+ throw new BrowserRedirectException( addHrefPrefix( contextPath, path ), e.getRelocationType() );
}
catch ( XMLException e )
{
@@ -935,6 +933,16 @@ public class ArchivaDavResourceFactory
return archivaLocator;
}
+ private String addHrefPrefix( String contextPath, String path ) {
+ String prefix = archivaConfiguration.getConfiguration().getWebapp().getUi().getApplicationUrl();
+ if (prefix == null || prefix.isEmpty()) {
+ prefix = contextPath;
+ }
+ return prefix + ( StringUtils.startsWith( path, "/" ) ? "" :
+ ( StringUtils.endsWith( prefix, "/" ) ? "" : "/" ) )
+ + path;
+ }
+
private static class LogicalResource
{
private String path;