mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-04 21:09:13 +00:00
Added a multipart form-data compliance configuration
Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
4a8c586760
commit
87498220bc
@ -65,6 +65,7 @@
|
||||
<Set name="blockingTimeout"><Property name="jetty.httpConfig.blockingTimeout" default="-1"/></Set>
|
||||
<Set name="persistentConnectionsEnabled"><Property name="jetty.httpConfig.persistentConnectionsEnabled" default="true"/></Set>
|
||||
<Set name="cookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.cookieCompliance" default="RFC6265"/></Arg></Call></Set>
|
||||
<Set name="multiPartFormDataCompliance"><Call class="org.eclipse.jetty.http.MultiPartFormDataCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.multiPartFormDataCompliance" default="RFC7578"/></Arg></Call></Set>
|
||||
</New>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
|
@ -65,6 +65,9 @@ etc/jetty.xml
|
||||
## Cookie compliance mode of: RFC2965, RFC6265
|
||||
# jetty.httpConfig.cookieCompliance=RFC6265
|
||||
|
||||
## multipart/form-data compliance mode of: LEGACY(slow), RFC7578(fast)
|
||||
# jetty.httpConfig.multiPartFormDataCompliance=LEGACY
|
||||
|
||||
### Server configuration
|
||||
## Whether ctrl+c on the console gracefully stops the Jetty server
|
||||
# jetty.server.stopAtShutdown=true
|
||||
|
@ -47,7 +47,6 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
public class HttpConfiguration
|
||||
{
|
||||
public static final String SERVER_VERSION = "Jetty(" + Jetty.VERSION + ")";
|
||||
|
||||
private final List<Customizer> _customizers=new CopyOnWriteArrayList<>();
|
||||
private final Trie<Boolean> _formEncodedMethods = new TreeTrie<>();
|
||||
private int _outputBufferSize=32*1024;
|
||||
@ -68,6 +67,7 @@ public class HttpConfiguration
|
||||
private long _minRequestDataRate;
|
||||
private long _minResponseDataRate;
|
||||
private CookieCompliance _cookieCompliance = CookieCompliance.RFC6265;
|
||||
private MultiPartFormDataCompliance _multiPartCompliance = MultiPartFormDataCompliance.LEGACY; // TODO change default in jetty-10
|
||||
private boolean _notifyRemoteAsyncErrors = true;
|
||||
|
||||
/**
|
||||
@ -536,6 +536,22 @@ public class HttpConfiguration
|
||||
return _cookieCompliance.equals(compliance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the compliance level for multipart/form-data handling.
|
||||
*
|
||||
* @param multiPartCompliance The multipart/form-data compliance level.
|
||||
*/
|
||||
public void setMultiPartFormDataCompliance(MultiPartFormDataCompliance multiPartCompliance)
|
||||
{
|
||||
// TODO change default in jetty-10
|
||||
_multiPartCompliance = multiPartCompliance==null?MultiPartFormDataCompliance.LEGACY:multiPartCompliance;
|
||||
}
|
||||
|
||||
public MultiPartFormDataCompliance getMultipartFormDataCompliance()
|
||||
{
|
||||
return _multiPartCompliance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param notifyRemoteAsyncErrors whether remote errors, when detected, are notified to async applications
|
||||
*/
|
||||
|
@ -0,0 +1,38 @@
|
||||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
/**
|
||||
* The compliance level for parsing <code>multiPart/form-data</code>
|
||||
*
|
||||
*/
|
||||
public enum MultiPartFormDataCompliance
|
||||
{
|
||||
/**
|
||||
* Legacy <code>multiPart/form-data</code> parsing which is slow but forgiving.
|
||||
* It will accept non compliant preambles and inconsistent line termination.
|
||||
* @see org.eclipse.jetty.util.MultiPartInputStreamParser
|
||||
*/
|
||||
LEGACY,
|
||||
/**
|
||||
* RFC7578 compliant parsing that is a fast but strict parser.
|
||||
* @see org.eclipse.jetty.http.MultiPartFormInputStream
|
||||
*/
|
||||
RFC7578
|
||||
}
|
@ -2328,6 +2328,9 @@ public class Request implements HttpServletRequest
|
||||
|
||||
private Collection<Part> getParts(MultiMap<String> params) throws IOException, ServletException
|
||||
{
|
||||
// TODO use this
|
||||
MultiPartFormDataCompliance compliance = getHttpChannel().getHttpConfiguration().getMultipartFormDataCompliance();
|
||||
|
||||
if (_multiPartInputStream == null)
|
||||
_multiPartInputStream = (MultiPartInputStreamParser)getAttribute(__MULTIPART_INPUT_STREAM);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user