Revert "WICKET-4715 WebApplication doesn't recognize if an incoming request is multipart."
This reverts commit 4fc82e3598ec6d790fe13c05ef99b1a69095779e. Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/3355b5af Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/3355b5af Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/3355b5af Branch: refs/heads/master Commit: 3355b5af68a238855a602f5161980d65024a1e92 Parents: c9c1e49 Author: svenmeier <[email protected]> Authored: Mon Oct 1 08:17:33 2012 +0200 Committer: svenmeier <[email protected]> Committed: Mon Oct 1 08:17:33 2012 +0200 ---------------------------------------------------------------------- .../org/apache/wicket/markup/html/form/Form.java | 9 +-- .../wicket/protocol/http/WebApplication.java | 19 ------ .../protocol/http/MultiPartTestApplication.java | 49 --------------- .../http/servlet/ServletWebRequestTest.java | 22 ------- 4 files changed, 2 insertions(+), 97 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/3355b5af/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java index d3c9b8b..5021167 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java @@ -147,11 +147,6 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener private static final String HIDDEN_DIV_START = "<div style=\"width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden\">"; /** - * The value of HTMLFormElement's <code>enctype</code> attribute needed for file uploading. - */ - public static final String ENCTYPE_MULTIPART_FORM_DATA = "multipart/form-data"; - - /** * Visitor used for validation * * @author Igor Vaynberg (ivaynberg) @@ -1544,7 +1539,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener tag.put("method", METHOD_POST.toLowerCase(Locale.ENGLISH)); } - tag.put("enctype", ENCTYPE_MULTIPART_FORM_DATA); + tag.put("enctype", "multipart/form-data"); // // require the application-encoding for multipart/form-data to be sure to // get multipart-uploaded characters with the proper encoding on the following @@ -1559,7 +1554,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener { // sanity check String enctype = (String)tag.getAttributes().get("enctype"); - if (ENCTYPE_MULTIPART_FORM_DATA.equalsIgnoreCase(enctype)) + if ("multipart/form-data".equalsIgnoreCase(enctype)) { // though not set explicitly in Java, this is a multipart // form http://git-wip-us.apache.org/repos/asf/wicket/blob/3355b5af/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java index 117947d..42ab5d1 100644 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java @@ -44,7 +44,6 @@ import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.AutoLabelResolver; import org.apache.wicket.markup.html.form.AutoLabelTextResolver; -import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.pages.AccessDeniedPage; import org.apache.wicket.markup.html.pages.InternalErrorPage; import org.apache.wicket.markup.html.pages.PageExpiredErrorPage; @@ -80,7 +79,6 @@ import org.apache.wicket.util.lang.Args; import org.apache.wicket.util.lang.PackageName; import org.apache.wicket.util.string.Strings; import org.apache.wicket.util.time.Duration; -import org.apache.wicket.util.upload.FileUploadException; import org.apache.wicket.util.watch.IModificationWatcher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -488,23 +486,6 @@ public abstract class WebApplication extends Application WebRequest webRequest = newWebRequest(servletRequest, filterPath); - String contentType = servletRequest.getContentType(); - String method = servletRequest.getMethod(); - - if (webRequest instanceof ServletWebRequest && Form.METHOD_POST.equalsIgnoreCase(method) && - Strings.isEmpty(contentType) == false && contentType.toLowerCase().startsWith(Form.ENCTYPE_MULTIPART_FORM_DATA)) - { - try - { - return ((ServletWebRequest)webRequest).newMultipartWebRequest( - getApplicationSettings().getDefaultMaximumUploadSize(), "externalForm"); - } - catch (FileUploadException e) - { - throw new RuntimeException(e); - } - } - return webRequest; } http://git-wip-us.apache.org/repos/asf/wicket/blob/3355b5af/wicket-core/src/test/java/org/apache/wicket/protocol/http/MultiPartTestApplication.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/MultiPartTestApplication.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/MultiPartTestApplication.java deleted file mode 100644 index 6805d76..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/MultiPartTestApplication.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.wicket.protocol.http; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.wicket.Page; -import org.apache.wicket.request.http.WebRequest; -import org.apache.wicket.util.tester.DummyHomePage; - -/** - * An extension of WebApplication just to make its #createWebRequest() public - */ -public class MultiPartTestApplication extends WebApplication -{ - /** - * Extend #createWebRequest() just to make it public - * @param servletRequest - * the current HTTP Sservlet request - * @param filterPath - * the filter mapping read from web.xml - * @return - */ - @Override - public WebRequest createWebRequest(HttpServletRequest servletRequest, String filterPath) - { - return super.createWebRequest(servletRequest, filterPath); - } - - @Override - public Class<? extends Page> getHomePage() - { - return DummyHomePage.class; - } -}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/3355b5af/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java index df6abdb..4a06a16 100644 --- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java @@ -22,8 +22,6 @@ import org.apache.wicket.MarkupContainer; import org.apache.wicket.Page; import org.apache.wicket.markup.IMarkupResourceStreamProvider; import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.protocol.http.MultiPartTestApplication; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.protocol.http.mock.MockHttpServletRequest; import org.apache.wicket.request.Url; @@ -135,26 +133,6 @@ public class ServletWebRequestTest extends Assert tester.startPage(new CustomRequestPage()); } - /** - * https://issues.apache.org/jira/browse/WICKET-4715 - */ - @Test - public void multiPartWebRequest() - { - MultiPartTestApplication application = new MultiPartTestApplication(); - new WicketTester(application); // inits the app - - MockHttpServletRequest httpRequest = new MockHttpServletRequest(null, null, null); - httpRequest.setURL("/"); - httpRequest.setParameter("some", "parameter"); - httpRequest.setMethod(Form.METHOD_POST); - httpRequest.setUseMultiPartContentType(true); - - WebRequest webRequest = application.createWebRequest(httpRequest, "/"); - assertTrue(webRequest instanceof MultipartServletWebRequest); - } - - private static class CustomRequestPage extends WebPage implements IMarkupResourceStreamProvider { private static final long serialVersionUID = 1L;
