diff options
author | Jan Bartel | 2010-10-25 08:42:38 +0000 |
---|---|---|
committer | Jan Bartel | 2010-10-25 08:42:38 +0000 |
commit | 8e3b1027b2a52cc7a3538439029c566c0555f953 (patch) | |
tree | be04c2c6f15f9702c002db89cef2ce1286fcd01b | |
parent | 13c5b100722f0a1ddb988e34437f4e2cd77872df (diff) | |
download | org.eclipse.jetty.project-8e3b1027b2a52cc7a3538439029c566c0555f953.tar.gz org.eclipse.jetty.project-8e3b1027b2a52cc7a3538439029c566c0555f953.tar.xz org.eclipse.jetty.project-8e3b1027b2a52cc7a3538439029c566c0555f953.zip |
327489 - Change meaning of @MultipartConfig to match servlet spec 3.0 maintenance release 3.0a
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/branches/jetty-8@2402 7e9141cc-0065-0410-87d8-b60c137991c4
7 files changed, 49 insertions, 18 deletions
diff --git a/VERSION.txt b/VERSION.txt index 4aefc7310e..fdfc2f49d2 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -5,6 +5,7 @@ jetty-8.0.0.M2-SNAPSHOT + 324505 Request.login method must throw ServletException if it cant login + 324872 allow disabling listener restriction from using *Registration interfaces + 327416 Change meaning of @HandlesTypes in line with latest interpretation by JSR315 + + 327489 Change meaning of @MultipartConfig to match servlet spec 3.0 maintenance release 3.0a from jetty-7.2-SNAPSHOT + 328306 Serialization of FormAuthentication diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationDecorator.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationDecorator.java index 42685c6f12..7c9fe087af 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationDecorator.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationDecorator.java @@ -45,6 +45,7 @@ public class AnnotationDecorator implements Decorator _introspector.registerHandler(new PostConstructAnnotationHandler(context)); _introspector.registerHandler(new PreDestroyAnnotationHandler(context)); _introspector.registerHandler(new DeclareRolesAnnotationHandler(context)); + _introspector.registerHandler(new MultiPartConfigAnnotationHandler(context)); } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index f0d0382f6d..c24a62ce18 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -14,6 +14,7 @@ package org.eclipse.jetty.server; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -1875,8 +1876,11 @@ public class Request implements HttpServletRequest return null; if (_multiPartInputStream == null) - _multiPartInputStream = new MultiPartInputStream(getInputStream(), getContentType(),(MultipartConfigElement)getAttribute(__MULTIPART_CONFIG_ELEMENT)); - + { + _multiPartInputStream = new MultiPartInputStream(getInputStream(), + getContentType(),(MultipartConfigElement)getAttribute(__MULTIPART_CONFIG_ELEMENT), + (_context != null?(File)_context.getAttribute("javax.servlet.context.tempdir"):null)); + } return _multiPartInputStream.getPart(name); } @@ -1887,8 +1891,11 @@ public class Request implements HttpServletRequest return Collections.emptyList(); if (_multiPartInputStream == null) - _multiPartInputStream = new MultiPartInputStream(getInputStream(), getContentType(),(MultipartConfigElement)getAttribute(__MULTIPART_CONFIG_ELEMENT)); - + { + _multiPartInputStream = new MultiPartInputStream(getInputStream(), + getContentType(),(MultipartConfigElement)getAttribute(__MULTIPART_CONFIG_ELEMENT), + (_context != null?(File)_context.getAttribute("javax.servlet.context.tempdir"):null)); + } return _multiPartInputStream.getParts(); } diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java index eaa77ad0ba..364f8186de 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java @@ -63,6 +63,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope private String _runAsRole; private RunAsToken _runAsToken; private IdentityService _identityService; + private Registration _registration; private transient Servlet _servlet; @@ -672,7 +673,9 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope public ServletRegistration.Dynamic getRegistration() { - return new Registration(); + if (_registration == null) + _registration = new Registration(); + return _registration; } /* -------------------------------------------------------- */ diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java index 5553ad4141..5bc0ab8d16 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java @@ -128,7 +128,7 @@ public class MultiPartFilter implements Filter String content_type=srequest.getContentType(); MultipartConfigElement config = new MultipartConfigElement(tempdir.getCanonicalPath(), _maxFileSize, _maxRequestSize, _fileOutputBuffer); - MultiPartInputStream mpis = new MultiPartInputStream(in, content_type, config); + MultiPartInputStream mpis = new MultiPartInputStream(in, content_type, config, tempdir); try diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStream.java b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStream.java index 292d0ee741..1da451ca86 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStream.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStream.java @@ -52,6 +52,7 @@ public class MultiPartInputStream protected MultiMap _map; protected Map<String, Part> _parts; protected File _tmpDir; + protected File _contextTmpDir; @@ -283,14 +284,18 @@ public class MultiPartInputStream * @param in Request input stream * @param contentType Content-Type header * @param config MultipartConfigElement + * @param contextTmpDir javax.servlet.context.tempdir */ - public MultiPartInputStream (InputStream in, String contentType, MultipartConfigElement config) + public MultiPartInputStream (InputStream in, String contentType, MultipartConfigElement config, File contextTmpDir) { _in = new BufferedInputStream(in); _contentType = contentType; _config = config; + _contextTmpDir = contextTmpDir; + if (_contextTmpDir == null) + _contextTmpDir = new File (System.getProperty(System.getProperty("java.io.tmpdir"))); if (_config == null) - _config = __DEFAULT_MULTIPART_CONFIG; + _config = new MultipartConfigElement(_contextTmpDir.getAbsolutePath()); } @@ -335,14 +340,23 @@ public class MultiPartInputStream return; //sort out the location to which to write the files - String location = __DEFAULT_MULTIPART_CONFIG.getLocation(); - location = ("".equals(_config.getLocation())? location : _config.getLocation()); - - _tmpDir = new File(location); + + if (_config.getLocation() == null) + _tmpDir = _contextTmpDir; + else if ("".equals(_config.getLocation())) + _tmpDir = _contextTmpDir; + else + { + File f = new File (_config.getLocation()); + if (f.isAbsolute()) + _tmpDir = f; + else + _tmpDir = new File (_contextTmpDir, _config.getLocation()); + } + if (!_tmpDir.exists()) _tmpDir.mkdirs(); - String boundary="--"+value(_contentType.substring(_contentType.indexOf("boundary="))); byte[] byteBoundary=(boundary+"--").getBytes(StringUtil.__ISO_8859_1); diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiPartInputStreamTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiPartInputStreamTest.java index b4835a48bd..ea9e16f750 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/MultiPartInputStreamTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/MultiPartInputStreamTest.java @@ -54,7 +54,8 @@ public class MultiPartInputStreamTest extends TestCase MultipartConfigElement config = new MultipartConfigElement(_dirname, 1024, 3072, 50); MultiPartInputStream mpis = new MultiPartInputStream(new ByteArrayInputStream(_multi.getBytes()), "Content-type: text/plain", - config); + config, + new File(_dirname)); assertTrue(mpis.getParts().isEmpty()); } @@ -64,7 +65,8 @@ public class MultiPartInputStreamTest extends TestCase MultipartConfigElement config = new MultipartConfigElement(_dirname); MultiPartInputStream mpis = new MultiPartInputStream(new ByteArrayInputStream(_multi.getBytes()), _contentType, - config); + config, + new File(_dirname)); Collection<Part> parts = mpis.getParts(); assertFalse(parts.isEmpty()); } @@ -75,7 +77,8 @@ public class MultiPartInputStreamTest extends TestCase MultipartConfigElement config = new MultipartConfigElement(_dirname, 60, 100, 50); MultiPartInputStream mpis = new MultiPartInputStream(new ByteArrayInputStream(_multi.getBytes()), _contentType, - config); + config, + new File(_dirname)); try { @@ -94,7 +97,8 @@ public class MultiPartInputStreamTest extends TestCase MultipartConfigElement config = new MultipartConfigElement(_dirname, 40, 1024, 30); MultiPartInputStream mpis = new MultiPartInputStream(new ByteArrayInputStream(_multi.getBytes()), _contentType, - config); + config, + new File(_dirname)); try { @@ -114,7 +118,8 @@ public class MultiPartInputStreamTest extends TestCase MultipartConfigElement config = new MultipartConfigElement(_dirname, 1024, 3072, 50); MultiPartInputStream mpis = new MultiPartInputStream(new ByteArrayInputStream(_multi.getBytes()), _contentType, - config); + config, + new File(_dirname)); Collection<Part> parts = mpis.getParts(); assertEquals(2, parts.size()); |