Author: remy.maucherat(a)jboss.com
Date: 2011-06-20 04:53:55 -0400 (Mon, 20 Jun 2011)
New Revision: 1740
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/connector/Response.java
trunk/webapps/docs/changelog.xml
Log:
- Add custom IS/OS fields to allow some wrapping by valves. Hopefully won't cause
issues.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2011-06-14 14:56:59 UTC (rev
1739)
+++ trunk/java/org/apache/catalina/connector/Request.java 2011-06-20 08:53:55 UTC (rev
1740)
@@ -347,6 +347,18 @@
/**
+ * Application input stream.
+ */
+ protected ServletInputStream applicationInputStream = null;
+
+
+ /**
+ * Application reader.
+ */
+ protected BufferedReader applicationReader = null;
+
+
+ /**
* User principal.
*/
protected Principal userPrincipal = null;
@@ -525,6 +537,8 @@
inputBuffer.recycle();
usingInputStream = false;
usingReader = false;
+ applicationInputStream = null;
+ applicationReader = null;
userPrincipal = null;
subject = null;
sessionParsed = false;
@@ -855,16 +869,6 @@
}
/**
- * Set the input stream associated with this Request.
- *
- * @param stream The new input stream
- */
- public void setStream(InputStream stream) {
- // Ignore
- }
-
-
- /**
* URI byte to char converter (not recycled).
*/
protected B2CConverter URIConverter = null;
@@ -1215,6 +1219,9 @@
throw new IllegalStateException
(sm.getString("coyoteRequest.getInputStream.ise"));
+ if (applicationInputStream != null) {
+ return applicationInputStream;
+ }
usingInputStream = true;
if (inputStream == null) {
inputStream = new CoyoteInputStream(inputBuffer);
@@ -1224,6 +1231,11 @@
}
+ public void setInputStream(ServletInputStream inputStream) {
+ applicationInputStream = inputStream;
+ }
+
+
/**
* Return the preferred Locale that the client will accept content in,
* based on the value for the first <code>Accept-Language</code> header
@@ -1362,6 +1374,9 @@
throw new IllegalStateException
(sm.getString("coyoteRequest.getReader.ise"));
+ if (applicationReader != null) {
+ return applicationReader;
+ }
usingReader = true;
inputBuffer.checkConverter();
if (reader == null) {
@@ -1371,7 +1386,17 @@
}
+
+ /**
+ * Replaces the reader with an application provided one.
+ *
+ * @param reader
+ */
+ public void setReader(BufferedReader reader) {
+ applicationReader = reader;
+ }
+
/**
* Return the real path of the specified virtual path.
*
Modified: trunk/java/org/apache/catalina/connector/Response.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Response.java 2011-06-14 14:56:59 UTC (rev
1739)
+++ trunk/java/org/apache/catalina/connector/Response.java 2011-06-20 08:53:55 UTC (rev
1740)
@@ -218,6 +218,18 @@
/**
+ * Application output stream.
+ */
+ protected ServletOutputStream applicationOutputStream = null;
+
+
+ /**
+ * Using writer flag.
+ */
+ protected PrintWriter applicationWriter = null;
+
+
+ /**
* URL encoder.
*/
protected UEncoder urlEncoder = new UEncoder();
@@ -241,6 +253,8 @@
outputBuffer.recycle();
usingOutputStream = false;
usingWriter = false;
+ applicationOutputStream = null;
+ applicationWriter = null;
appCommitted = false;
included = false;
error = false;
@@ -393,16 +407,6 @@
/**
- * Set the output stream associated with this Response.
- *
- * @param stream The new output stream
- */
- public void setStream(OutputStream stream) {
- // This method is evil
- }
-
-
- /**
* Set the suspended flag.
*
* @param suspended The new suspended flag value
@@ -567,6 +571,10 @@
throw new IllegalStateException
(sm.getString("coyoteResponse.getOutputStream.ise"));
+ if (applicationOutputStream != null) {
+ return applicationOutputStream;
+ }
+
usingOutputStream = true;
if (outputStream == null) {
outputStream = new CoyoteOutputStream(outputBuffer);
@@ -575,7 +583,12 @@
}
+
+ public void setOutputStream(ServletOutputStream outputStream) {
+ applicationOutputStream = outputStream;
+ }
+
/**
* Return the Locale assigned to this response.
*/
@@ -598,6 +611,10 @@
throw new IllegalStateException
(sm.getString("coyoteResponse.getWriter.ise"));
+ if (applicationWriter != null) {
+ return applicationWriter;
+ }
+
if (Globals.STRICT_SERVLET_COMPLIANCE) {
/*
* If the response's character encoding has not been specified as
@@ -624,6 +641,11 @@
}
+ public void setWriter(PrintWriter writer) {
+ applicationWriter = writer;
+ }
+
+
/**
* Has the output of this response already been committed?
*/
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2011-06-14 14:56:59 UTC (rev 1739)
+++ trunk/webapps/docs/changelog.xml 2011-06-20 08:53:55 UTC (rev 1740)
@@ -25,6 +25,10 @@
<fix>
<bug>51348</bug>: WebDAV lock processing NPE fix. (markt)
</fix>
+ <update>
+ Allow valves to replace the IS/reader and OS/writer that gets returned to the
+ applications. (remm)
+ </update>
</changelog>
</subsection>
</section>
Show replies by date