fixed path of MultiPartFormDataCompliance in jetty.xml

added some debug info
changes to jetty test webapp to display parts from multi-part forms

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2018-04-04 11:18:57 +10:00
parent 379a8d6928
commit 4a0e4294b9
5 changed files with 31 additions and 17 deletions

View File

@ -95,7 +95,7 @@ public class MultiPartFormInputStream
@Override
public String toString()
{
return String.format("Part{n=%s,fn=%s,ct=%s,s=%d,t=%b,f=%s}",_name,_filename,_contentType,_size,_temporary,_file);
return String.format("Part{n=%s,fn=%s,ct=%s,s=%d,tmp=%b,file=%s}",_name,_filename,_contentType,_size,_temporary,_file);
}
protected void setContentType(String contentType)

View File

@ -65,7 +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>
<Set name="multiPartFormDataCompliance"><Call class="org.eclipse.jetty.server.MultiPartFormDataCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.multiPartFormDataCompliance" default="RFC7578"/></Arg></Call></Set>
</New>
<!-- =========================================================== -->

View File

@ -2395,6 +2395,8 @@ public class Request implements HttpServletRequest
private MultiParts newMultiParts(ServletInputStream inputStream, String contentType, MultipartConfigElement config, Object object) throws IOException
{
MultiPartFormDataCompliance compliance = getHttpChannel().getHttpConfiguration().getMultipartFormDataCompliance();
if(LOG.isDebugEnabled())
LOG.debug("newMultiParts {} {}",compliance, this);
switch(compliance)
{

View File

@ -29,6 +29,7 @@ import java.io.Reader;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
@ -54,6 +55,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.http.Part;
/**
@ -579,6 +581,27 @@ public class Dump extends HttpServlet
}
}
try
{
Collection<Part> parts = request.getParts();
if (parts!=null && !parts.isEmpty())
{
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Parts:</big></th>");
for (Part p : parts)
{
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">"+notag(p.getName())+":&nbsp;</th>");
pout.write("<td>"+p+"</td>");
}
}
}
catch(ServletException e)
{
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>No Parts!</big></th>");
}
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Cookies:</big></th>");
Cookie[] cookies = request.getCookies();

View File

@ -46,21 +46,6 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>MultiPart</filter-name>
<filter-class>org.eclipse.jetty.servlets.MultiPartFilter</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>deleteFiles</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MultiPart</filter-name>
<url-pattern>/dump/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>com.acme.LoginServlet</servlet-class>
@ -90,6 +75,10 @@
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
<run-as><role-name>admin</role-name></run-as>
<multipart-config>
<location>upload</location>
<file-size-threshold>4096</file-size-threshold>
</multipart-config>
</servlet>
<servlet-mapping>