You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pe...@apache.org on 2010/09/10 18:47:54 UTC
svn commit: r995862 -
/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
Author: pete
Date: Fri Sep 10 16:47:54 2010
New Revision: 995862
URL: http://svn.apache.org/viewvc?rev=995862&view=rev
Log:
some clarification on truncation Last-Modified down to the nearest second for modification check
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java?rev=995862&r1=995861&r2=995862&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java Fri Sep 10 16:47:54 2010
@@ -36,7 +36,7 @@ import org.apache.wicket.util.lang.Args;
/**
* Convenience resource implementation. The subclass must implement
* {@link #newResourceResponse(org.apache.wicket.request.resource.IResource.Attributes)} method.
- *
+ *
* @author Matej Knopp
*/
public abstract class AbstractResource implements IResource
@@ -54,7 +54,7 @@ public abstract class AbstractResource i
/**
* Override this method to return a {@link ResourceResponse} for the request.
- *
+ *
* @param attributes request attributes
* @return resource data instance
*/
@@ -62,7 +62,7 @@ public abstract class AbstractResource i
/**
* Represents data used to configure response and write resource data.
- *
+ *
* @author Matej Knopp
*/
public static class ResourceResponse
@@ -90,7 +90,7 @@ public abstract class AbstractResource i
/**
* Sets the error code for resource. If there is an error code set the data will not be
* rendered and the code will be sent to client.
- *
+ *
* @param errorCode error code
*/
public void setError(Integer errorCode)
@@ -101,7 +101,7 @@ public abstract class AbstractResource i
/**
* Sets the error code and message for resource. If there is an error code set the data will
* not be rendered and the code and message will be sent to client.
- *
+ *
* @param errorCode error code
* @param errorMessage
* error message
@@ -130,7 +130,7 @@ public abstract class AbstractResource i
/**
* Sets the file name of the resource.
- *
+ *
* @param fileName file name
*/
public void setFileName(String fileName)
@@ -148,9 +148,9 @@ public abstract class AbstractResource i
/**
* Determines whether the resource will be inline or an attachment.
- *
+ *
* @see ContentDisposition
- *
+ *
* @param contentDisposition content disposition (attachment or inline)
*/
public void setContentDisposition(ContentDisposition contentDisposition)
@@ -170,7 +170,7 @@ public abstract class AbstractResource i
/**
* Sets the content type for the resource. If no content type is set it will be determined
* by the extension.
- *
+ *
* @param contentType content type (also known as mime type)
*/
public void setContentType(String contentType)
@@ -193,7 +193,7 @@ public abstract class AbstractResource i
/**
* Sets the text encoding for the resource. The encoding is only used if the content type
* indicates a textual resource.
- *
+ *
* @param textEncoding character encoding of text body
*/
public void setTextEncoding(String textEncoding)
@@ -212,7 +212,7 @@ public abstract class AbstractResource i
/**
* Sets the content length (in bytes) of the data. Content length is optional but it's
* recommended to set it so that the browser can show download progress.
- *
+ *
* @param contentLength length of response body
*/
public void setContentLength(long contentLength)
@@ -233,7 +233,7 @@ public abstract class AbstractResource i
* recommended to set the date. If the date is set properly Wicket can check the
* <code>If-Modified-Since</code> to determine if the actuall data really needs to be sent
* to client.
- *
+ *
* @param lastModified last modification date
*/
public void setLastModified(Date lastModified)
@@ -253,7 +253,7 @@ public abstract class AbstractResource i
* Check to determine if the resource data needs to be written. This method checks the
* <code>If-Modified-Since</code> request header and compares it to lastModified property.
* In order for this method to work {@link #setLastModified(Date)} has to be called first.
- *
+ *
* @param attributes request attributes
* @return <code>true</code> if the resource data does need to be written,
* <code>false</code> otherwise.
@@ -266,7 +266,11 @@ public abstract class AbstractResource i
if (ifModifiedSince != null && lastModified != null)
{
- // Round down to the nearest second for a proper compare
+ // [Last-Modified] headers have a maximum precision of one second
+ // so we have to truncate the milliseconds part for a proper compare.
+ // that's stupid, since changes within one second will not be reliably
+ // detected by the client ... any hint or clarification to improve this
+ // situation will be appreciated...
long modified = this.lastModified.getTime() / 1000 * 1000;
return ifModifiedSince.getTime() < modified;
@@ -280,9 +284,9 @@ public abstract class AbstractResource i
/**
* Cachable resources are cached on client. This flag affects the <code>Expires</code> and
* <code>Cache-Control</code> headers.
- *
+ *
* @see #setCacheDuration(long)
- *
+ *
* @param cacheable resource may be cached (true/false)
*/
public void setCacheable(boolean cacheable)
@@ -301,7 +305,7 @@ public abstract class AbstractResource i
/**
* Sets the duration for which this resource should be cached on client (in seconds). #see
* {@link IResourceSettings#setDefaultCacheDuration(int)}
- *
+ *
* @param cacheDuration caching duration in seconds
*/
public void setCacheDuration(long cacheDuration)
@@ -324,7 +328,7 @@ public abstract class AbstractResource i
* It is necessary to set the {@link WriteCallback} if
* {@link #dataNeedsToBeWritten(org.apache.wicket.request.resource.IResource.Attributes)} returns
* <code>true</code> and {@link #setError(Integer)} has not been called.
- *
+ *
* @param writeCallback write callback
*/
public void setWriteCallback(final WriteCallback writeCallback)
@@ -344,7 +348,7 @@ public abstract class AbstractResource i
/**
* Configure the web response header for client cache control.
- *
+ *
* @param request web request
* @param response web response
* @param data resource data
@@ -377,7 +381,7 @@ public abstract class AbstractResource i
}
/**
- *
+ *
* @see org.apache.wicket.request.resource.IResource#respond(org.apache.wicket.request.resource.IResource.Attributes)
*/
public final void respond(final Attributes attributes)
@@ -469,21 +473,21 @@ public abstract class AbstractResource i
/**
* Callback invoked when resource data needs to be written to response. Subclass needs to
* implement the {@link #writeData(org.apache.wicket.request.resource.IResource.Attributes)} method.
- *
+ *
* @author Matej Knopp
*/
public static abstract class WriteCallback
{
/**
* Write the resource data to response.
- *
+ *
* @param attributes request attributes
*/
public abstract void writeData(Attributes attributes);
/**
* Convenience method to write an {@link InputStream} to response.
- *
+ *
* @param attributes request attributes
* @param stream input stream
*/