greenrd 00/11/22 02:41:15
Modified: . changes.xml
src/org/apache/cocoon/processor/xslt XSLTProcessor.java
Log:
fixed proxy behaviour for multiple user agents
Revision Changes Path
1.156 +5 -0 xml-cocoon/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/changes.xml,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -r1.155 -r1.156
--- changes.xml 2000/11/22 00:03:44 1.155
+++ changes.xml 2000/11/22 10:41:11 1.156
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.155 2000/11/22 00:03:44 greenrd Exp $
+ $Id: changes.xml,v 1.156 2000/11/22 10:41:11 greenrd Exp $
-->
<changes title="History of Changes">
@@ -18,6 +18,11 @@
</devs>
<release version="@version@" date="@date@">
+ <action dev="RDG" type="fix">
+ Added HTTP Vary header to responses where a selection is made
+ by Cocoon on the basis of a User-Agent header, in order to give
+ correct proxy behaviour.
+ </action>
<action dev="RDG" type="update" due-to="Ovidiu Predescu"
due-to-email="[EMAIL PROTECTED]">
Request headers (prefixed by R_) and cookies (prefixed by C_)
1.20 +17 -7
xml-cocoon/src/org/apache/cocoon/processor/xslt/XSLTProcessor.java
Index: XSLTProcessor.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xslt/XSLTProcessor.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- XSLTProcessor.java 2000/11/22 00:03:45 1.19
+++ XSLTProcessor.java 2000/11/22 10:41:13 1.20
@@ -1,4 +1,4 @@
-/*-- $Id: XSLTProcessor.java,v 1.19 2000/11/22 00:03:45 greenrd Exp $ --
+/*-- $Id: XSLTProcessor.java,v 1.20 2000/11/22 10:41:13 greenrd Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -73,7 +73,7 @@
* This class implements an XSLT processor.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version $Revision: 1.19 $ $Date: 2000/11/22 00:03:45 $
+ * @version $Revision: 1.20 $ $Date: 2000/11/22 10:41:13 $
*/
public class XSLTProcessor implements Actor, Processor, Status, Defaults,
Cacheable {
@@ -98,13 +98,14 @@
if (sheet != null) return sheet;
HttpServletRequest request = (HttpServletRequest)
parameters.get("request");
+ HttpServletResponse response = (HttpServletResponse) parameters.get
("response");
ServletContext context = (ServletContext) parameters.get("context");
String path = (String) parameters.get("path");
String browser = (String) parameters.get("browser");
Hashtable params = this.filterParameters(request);
try {
- Object resource = getResource(context, request, document, path,
browser);
+ Object resource = getResource(context, request, response,
document, path, browser);
Document stylesheet = getStylesheet(resource, request);
Document result = this.parser.createEmptyDocument();
return transformer.transform(document, path, stylesheet,
@@ -171,7 +172,9 @@
return valid_name;
}
- private Object getResource(ServletContext context, HttpServletRequest
request, Document document, String path, String browser) throws
ProcessorException {
+ private Object getResource(ServletContext context, HttpServletRequest
request,
+ HttpServletResponse response, Document document, String path, String
browser)
+ throws ProcessorException {
Object resource = null;
@@ -186,7 +189,7 @@
Object local = null;
try {
- if (url.charAt(0) == '#') {
+ if (url.charAt(0) == '#') { // does not support
useragent selection with fragments
return null;
} else if (url.charAt(0) == '/') {
local = new File(Utils.getRootpath(request,
context) + url);
@@ -205,10 +208,17 @@
if (media == null) {
resource = local;
if (browser == null) break;
- } else if (browser != null) {
- if (media.equals(browser)) {
- resource = local;
- break;
+ } else {
+ // set HTTP Vary header to notify proxies
+ if (!response.containsHeader ("Vary")) {
+ response.setHeader ("Vary", "User-Agent");
+ }
+
+ if (browser != null) {
+ if (media.equals(browser)) {
+ resource = local;
+ break;
+ }
}
}
}