in wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java [327:364]
public boolean resourceExists(String resourceName) throws TransferFailedException, AuthorizationException {
HttpURLConnection headConnection;
try {
Resource resource = new Resource(resourceName);
URL url = new URL(buildUrl(resource));
headConnection = (HttpURLConnection) url.openConnection(this.proxy);
addHeaders(headConnection);
headConnection.setRequestMethod("HEAD");
int statusCode = headConnection.getResponseCode();
String reasonPhrase = headConnection.getResponseMessage();
switch (statusCode) {
case HttpURLConnection.HTTP_OK:
return true;
case HttpURLConnection.HTTP_NOT_FOUND:
case HttpURLConnection.HTTP_GONE:
return false;
// TODO Move 401/407 to AuthenticationException after WAGON-587
case HttpURLConnection.HTTP_FORBIDDEN:
case HttpURLConnection.HTTP_UNAUTHORIZED:
case HttpURLConnection.HTTP_PROXY_AUTH:
throw new AuthorizationException(
formatAuthorizationMessage(buildUrl(resource), statusCode, reasonPhrase, getProxyInfo()));
default:
throw new TransferFailedException(
formatTransferFailedMessage(buildUrl(resource), statusCode, reasonPhrase, getProxyInfo()));
}
} catch (IOException e) {
throw new TransferFailedException("Error transferring file: " + e.getMessage(), e);
}
}