Grzegorz Kossakowski schrieb:
Grek (nickname/easier form for English speaking people) or Grzegorz (real name)
:-)
Sorry, Grek, I didn't know this! Would be interesting to know how your name
is pronounced? Does one simply skip the first "z"?
Could you also provide some minimal block setup where the bug occurs?
> This way we would think about writing test case for it.
Yup, but I still don't understand why it appears in that specific case
although I know multiple ways to fix it ;-)
Problem
=======
My sitemaps look like that (Note that I am running everything with a
NonCaching pipeline):
<transform src="servlet:/aaa.xsl" />
->
<generate src="servlet:resources:/bbb.xsl>
->
<read src="bbb.xsl"/>
<-
<serialize type="xml" />
<- // response is empty, because its misinterpreted as not modified
The response is misinterpreted as not modified, but it is not cached either
thus he returns an empty result.
The problem disappears when the generate/serialize of bbb.xsl is replaced by
a reader. This is because the ResourceReader behaves different than the
pipeline when the Last-Modified is set (see below).
Solutions
=========
Well, there are multiple fixes. The best one IMHO is to fix a bug in
HttpEnvironment.isResponseModified() [1]. It should *not* set the
Last-Modified value if it is invalid == -1 (which is the case if the servlet
source cannot determine the last modified value). The other two places where
this is set (ResourceReader [2] and LinkRewriterReader [3] .setupHeaders())
do a > 0 check:
if (lastModified > 0) {
response.setDateHeader("Last-Modified", lastModified);
}
AFAIK setting a "-1" last modified header is not according the HTTP spec,
one should not include the header in that case. But why am I the first one
to spot that problem? It's a central part of cocoon's caching algorithm.
WDYT?
Another way to fix that is by making sure
ServletConnection.getLastModified() returns 0 in case the header has the
value -1.
[1]
http://svn.apache.org/repos/asf/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
[2]
http://svn.apache.org/repos/asf/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/main/java/org/apache/cocoon/reading/ResourceReader.java
[3]
http://svn.apache.org/repos/asf/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/LinkRewriterReader.java
Alex
--
Alexander Klimetschek
http://www.mindquarry.com