nicer constructors
This commit is contained in:
parent
6d1e5c9a07
commit
0539b48b8a
|
@ -31,6 +31,16 @@ public class HostPortHttpField extends HttpField
|
||||||
public final String _host;
|
public final String _host;
|
||||||
public final int _port;
|
public final int _port;
|
||||||
|
|
||||||
|
public HostPortHttpField(String authority)
|
||||||
|
{
|
||||||
|
this(HttpHeader.HOST,HttpHeader.HOST.asString(),authority);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HostPortHttpField(HttpHeader header, String authority)
|
||||||
|
{
|
||||||
|
this(header,header.asString(),authority);
|
||||||
|
}
|
||||||
|
|
||||||
public HostPortHttpField(HttpHeader header, String name, String authority)
|
public HostPortHttpField(HttpHeader header, String name, String authority)
|
||||||
{
|
{
|
||||||
super(header,name,authority);
|
super(header,name,authority);
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.AsyncContext;
|
import javax.servlet.AsyncContext;
|
||||||
import javax.servlet.AsyncListener;
|
import javax.servlet.AsyncListener;
|
||||||
import javax.servlet.DispatcherType;
|
import javax.servlet.DispatcherType;
|
||||||
|
@ -51,8 +52,6 @@ import javax.servlet.ServletInputStream;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletRequestAttributeEvent;
|
import javax.servlet.ServletRequestAttributeEvent;
|
||||||
import javax.servlet.ServletRequestAttributeListener;
|
import javax.servlet.ServletRequestAttributeListener;
|
||||||
import javax.servlet.ServletRequestEvent;
|
|
||||||
import javax.servlet.ServletRequestListener;
|
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -75,7 +74,6 @@ import org.eclipse.jetty.server.session.AbstractSession;
|
||||||
import org.eclipse.jetty.util.Attributes;
|
import org.eclipse.jetty.util.Attributes;
|
||||||
import org.eclipse.jetty.util.AttributesMap;
|
import org.eclipse.jetty.util.AttributesMap;
|
||||||
import org.eclipse.jetty.util.IO;
|
import org.eclipse.jetty.util.IO;
|
||||||
import org.eclipse.jetty.util.MultiException;
|
|
||||||
import org.eclipse.jetty.util.MultiMap;
|
import org.eclipse.jetty.util.MultiMap;
|
||||||
import org.eclipse.jetty.util.MultiPartInputStreamParser;
|
import org.eclipse.jetty.util.MultiPartInputStreamParser;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
|
@ -131,42 +129,6 @@ public class Request implements HttpServletRequest
|
||||||
private final List<ServletRequestAttributeListener> _requestAttributeListeners=new ArrayList<>();
|
private final List<ServletRequestAttributeListener> _requestAttributeListeners=new ArrayList<>();
|
||||||
private final HttpInput _input;
|
private final HttpInput _input;
|
||||||
|
|
||||||
public static class MultiPartCleanerListener implements ServletRequestListener
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void requestDestroyed(ServletRequestEvent sre)
|
|
||||||
{
|
|
||||||
//Clean up any tmp files created by MultiPartInputStream
|
|
||||||
MultiPartInputStreamParser mpis = (MultiPartInputStreamParser)sre.getServletRequest().getAttribute(__MULTIPART_INPUT_STREAM);
|
|
||||||
if (mpis != null)
|
|
||||||
{
|
|
||||||
ContextHandler.Context context = (ContextHandler.Context)sre.getServletRequest().getAttribute(__MULTIPART_CONTEXT);
|
|
||||||
|
|
||||||
//Only do the cleanup if we are exiting from the context in which a servlet parsed the multipart files
|
|
||||||
if (context == sre.getServletContext())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mpis.deleteParts();
|
|
||||||
}
|
|
||||||
catch (MultiException e)
|
|
||||||
{
|
|
||||||
sre.getServletContext().log("Errors deleting multipart tmp files", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requestInitialized(ServletRequestEvent sre)
|
|
||||||
{
|
|
||||||
//nothing to do, multipart config set up by ServletHolder.handle()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean _secure;
|
private boolean _secure;
|
||||||
private boolean _asyncSupported = true;
|
private boolean _asyncSupported = true;
|
||||||
private boolean _newContext;
|
private boolean _newContext;
|
||||||
|
@ -2259,4 +2221,5 @@ public class Request implements HttpServletRequest
|
||||||
throw new ServletException(e);
|
throw new ServletException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class RequestTest
|
||||||
contextHandler.setContextPath("/foo");
|
contextHandler.setContextPath("/foo");
|
||||||
contextHandler.setResourceBase(".");
|
contextHandler.setResourceBase(".");
|
||||||
contextHandler.setHandler(new MultiPartRequestHandler(testTmpDir));
|
contextHandler.setHandler(new MultiPartRequestHandler(testTmpDir));
|
||||||
contextHandler.addEventListener(new Request.MultiPartCleanerListener()
|
contextHandler.addEventListener(new MultiPartCleanerListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -45,6 +45,7 @@ import javax.servlet.UnavailableException;
|
||||||
|
|
||||||
import org.eclipse.jetty.security.IdentityService;
|
import org.eclipse.jetty.security.IdentityService;
|
||||||
import org.eclipse.jetty.security.RunAsToken;
|
import org.eclipse.jetty.security.RunAsToken;
|
||||||
|
import org.eclipse.jetty.server.MultiPartCleanerListener;
|
||||||
import org.eclipse.jetty.server.Request;
|
import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.UserIdentity;
|
import org.eclipse.jetty.server.UserIdentity;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
|
@ -665,7 +666,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
//servlet calling Request.getPart() or Request.getParts()
|
//servlet calling Request.getPart() or Request.getParts()
|
||||||
|
|
||||||
ContextHandler ch = ContextHandler.getContextHandler(getServletHandler().getServletContext());
|
ContextHandler ch = ContextHandler.getContextHandler(getServletHandler().getServletContext());
|
||||||
ch.addEventListener(new Request.MultiPartCleanerListener());
|
ch.addEventListener(new MultiPartCleanerListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue