refined Resource "exists()" check for HTTP URLs to always return false for 404 status (SPR-7881)

This commit is contained in:
Juergen Hoeller 2011-11-28 21:11:57 +00:00
parent 2cb287a01b
commit fa9a7b18c6
1 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -100,9 +100,13 @@ public abstract class AbstractFileResolvingResource extends AbstractResource {
(con instanceof HttpURLConnection ? (HttpURLConnection) con : null);
if (httpCon != null) {
httpCon.setRequestMethod("HEAD");
if (httpCon.getResponseCode() == HttpURLConnection.HTTP_OK) {
int code = httpCon.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
return true;
}
else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
return false;
}
}
if (con.getContentLength() >= 0) {
return true;