Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 20088 invoked from network); 18 Oct 2004 13:10:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 18 Oct 2004 13:10:30 -0000 Received: (qmail 72554 invoked by uid 500); 18 Oct 2004 13:10:29 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 72502 invoked by uid 500); 18 Oct 2004 13:10:28 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 72489 invoked by uid 99); 18 Oct 2004 13:10:28 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 18 Oct 2004 06:10:26 -0700 Received: (qmail 20037 invoked by uid 65534); 18 Oct 2004 13:10:25 -0000 Date: 18 Oct 2004 13:10:25 -0000 Message-ID: <20041018131025.20034.qmail@minotaur.apache.org> From: unico@apache.org To: cvs@cocoon.apache.org Subject: svn commit: rev 55002 - cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: unico Date: Mon Oct 18 06:10:24 2004 New Revision: 55002 Added: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/ResponseWrapper.java Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Log: introduce WrappedResponse for preventing internal requests to modify the response headers as discussed here: http://marc.theaimsgroup.com/?t=109783260100005&r=1&w=2 Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Mon Oct 18 06:10:24 2004 @@ -27,6 +27,7 @@ import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Request; +import org.apache.cocoon.environment.Response; import org.apache.cocoon.util.BufferedOutputStream; @@ -37,7 +38,7 @@ * * @author Björn Lütkemeier * @author Carsten Ziegeler - * @version CVS $Id: EnvironmentWrapper.java,v 1.21 2004/06/25 15:36:38 cziegeler Exp $ + * @version CVS $Id$ */ public class EnvironmentWrapper extends AbstractEnvironment { @@ -90,7 +91,9 @@ info.queryString, this, info.rawMode); + Response response = new ResponseWrapper(ObjectModelHelper.getResponse(oldObjectModel)); this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, this.request); + this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, response); this.setURI(info.prefix, info.uri); } Added: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/ResponseWrapper.java ============================================================================== --- (empty file) +++ cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/ResponseWrapper.java Mon Oct 18 06:10:24 2004 @@ -0,0 +1,82 @@ +/* + * Copyright 1999-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.cocoon.environment.wrapper; + +import java.util.Locale; + +import org.apache.cocoon.environment.Cookie; +import org.apache.cocoon.environment.Response; + +/** + * This is a wrapper class for the Response object. + * It contains the same properties as the wrapped instance + * but swallows calls that would modify response headers. + */ +public class ResponseWrapper implements Response { + + private Response res; + + public ResponseWrapper(Response response) { + this.res = response; + } + + public String getCharacterEncoding() { + return res.getCharacterEncoding(); + } + + public void setLocale(Locale loc) { + res.setLocale(loc); + } + + public Locale getLocale() { + return res.getLocale(); + } + + public Cookie createCookie(String name, String value) { + return res.createCookie(name, value); + } + + public void addCookie(Cookie cookie) { + res.addCookie(cookie); + } + + public String encodeURL(String url) { + return res.encodeURL(url); + } + + public boolean containsHeader(String name) { + return res.containsHeader(name); + } + + public void setDateHeader(String name, long date) { + } + + public void addDateHeader(String name, long date) { + } + + public void setHeader(String name, String value) { + } + + public void addHeader(String name, String value) { + } + + public void setIntHeader(String name, int value) { + } + + public void addIntHeader(String name, int value) { + } + +}