You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/12/10 00:43:16 UTC
svn commit: r1549711 -
/tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
Author: markt
Date: Mon Dec 9 23:43:15 2013
New Revision: 1549711
URL: http://svn.apache.org/r1549711
Log:
Simplify assuming that the resources implementation will generate an InputStream from the cached byte array if one is available.
Modified:
tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
Modified: tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java?rev=1549711&r1=1549710&r2=1549711&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Mon Dec 9 23:43:15 2013
@@ -899,15 +899,15 @@ public class DefaultServlet
}
InputStream renderResult = null;
- if (resource.isDirectory()) {
- if (serveContent) {
+ if (serveContent) {
+ if (resource.isDirectory()) {
// Serve the directory browser
renderResult = render(getPathPrefix(request), resource);
+ } else {
+ renderResult = resource.getInputStream();
}
- }
- // Copy the input stream to our output stream (if requested)
- if (serveContent) {
+ // Copy the input stream to our output stream
try {
response.setBufferSize(output);
} catch (IllegalStateException e) {
@@ -1785,23 +1785,7 @@ public class DefaultServlet
throws IOException {
IOException exception = null;
- InputStream resourceInputStream = null;
-
- // Optimization: If the binary content has already been loaded, send
- // it directly
- if (resource.isFile()) {
- byte buffer[] = resource.getContent();
- if (buffer != null) {
- ostream.write(buffer, 0, buffer.length);
- return;
- }
- resourceInputStream = resource.getInputStream();
- } else {
- resourceInputStream = is;
- }
-
- InputStream istream = new BufferedInputStream
- (resourceInputStream, input);
+ InputStream istream = new BufferedInputStream(is, input);
// Copy the input stream to the output stream
exception = copyRange(istream, ostream);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org