refined Resource "exists()" check for HTTP URLs to always return false for 404 status (SPR-7881)
This commit is contained in:
parent
2cb287a01b
commit
fa9a7b18c6
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
(con instanceof HttpURLConnection ? (HttpURLConnection) con : null);
|
||||||
if (httpCon != null) {
|
if (httpCon != null) {
|
||||||
httpCon.setRequestMethod("HEAD");
|
httpCon.setRequestMethod("HEAD");
|
||||||
if (httpCon.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
int code = httpCon.getResponseCode();
|
||||||
|
if (code == HttpURLConnection.HTTP_OK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (con.getContentLength() >= 0) {
|
if (con.getContentLength() >= 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue