ensure we send a User-Agent header when requesting a remote repository

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1519362 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-09-02 07:47:22 +00:00
parent 02fc935ac9
commit 5d29b0e6ba
1 changed files with 19 additions and 0 deletions

View File

@ -20,8 +20,13 @@ package org.apache.archiva.webdav;
*/
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.commons.lang.StringUtils;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* UnauthenticatedRepositoryServlet
@ -46,4 +51,18 @@ public class UnauthenticatedRepositoryServlet
UnauthenticatedDavSessionProvider sessionProvider = new UnauthenticatedDavSessionProvider();
setDavSessionProvider( sessionProvider );
}
@Override
protected void service( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException
{
String userAgent = request.getHeader( "User-Agent" );
if ( StringUtils.isEmpty( userAgent ))
{
throw new ServletException( "User-Agent is not configured" );
}
super.service( request, response );
}
}