Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-11-03 23:13:40 -0500
committerGreg Wilkins2015-11-03 23:13:40 -0500
commit2737b19f73ad153c20e1762874558a5d62849f90 (patch)
tree8d8a4bce940bf6cb7d49f509e82ff7e01a60ca95
parentcd0cc2ef36a558d948bf26aff4f9e3519da2f823 (diff)
parent92cc44c1a333964163c0d47dabc0345586f6e36f (diff)
downloadorg.eclipse.jetty.project-2737b19f73ad153c20e1762874558a5d62849f90.tar.gz
org.eclipse.jetty.project-2737b19f73ad153c20e1762874558a5d62849f90.tar.xz
org.eclipse.jetty.project-2737b19f73ad153c20e1762874558a5d62849f90.zip
Merge branch 'master' into unix-socket
Conflicts: jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.javabin15796 -> 14206 bytes
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartContentProviderTest.java195
-rw-r--r--jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java4
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java3
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java2
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java65
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java8
-rw-r--r--jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java5
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilder.java19
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilderImpl.java56
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java4
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java9
12 files changed, 281 insertions, 89 deletions
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java b/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java
index 2d60c97fa3..dddff6a814 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java
Binary files differ
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartContentProviderTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartContentProviderTest.java
index daa91cf7d4..4ae83b23b8 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartContentProviderTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/util/MultiPartContentProviderTest.java
@@ -19,9 +19,11 @@
package org.eclipse.jetty.client.util;
import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -31,6 +33,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletException;
@@ -39,12 +43,14 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import org.eclipse.jetty.client.AbstractHttpClientServerTest;
+import org.eclipse.jetty.client.api.ContentProvider;
import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
-import org.eclipse.jetty.util.Fields;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.Assert;
@@ -99,7 +105,7 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
});
MultiPartContentProvider multiPart = new MultiPartContentProvider();
- multiPart.addPart(new MultiPartContentProvider.FieldPart(name, value, null));
+ multiPart.addFieldPart(name, new StringContentProvider(value), null);
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
.method(HttpMethod.POST)
@@ -110,11 +116,11 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
}
@Test
- public void testFieldWithContentType() throws Exception
+ public void testFieldWithOverridenContentType() throws Exception
{
String name = "field";
- String value = "\u20ac";
- Charset encoding = StandardCharsets.UTF_8;
+ String value = "\u00e8";
+ Charset encoding = StandardCharsets.ISO_8859_1;
start(new AbstractMultiPartHandler()
{
@Override
@@ -134,7 +140,10 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
});
MultiPartContentProvider multiPart = new MultiPartContentProvider();
- multiPart.addPart(new MultiPartContentProvider.FieldPart(name, value, encoding));
+ HttpFields fields = new HttpFields();
+ fields.put(HttpHeader.CONTENT_TYPE, "text/plain;charset=" + encoding.name());
+ BytesContentProvider content = new BytesContentProvider(value.getBytes(encoding));
+ multiPart.addFieldPart(name, content, fields);
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
.method(HttpMethod.POST)
@@ -145,7 +154,101 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
}
@Test
- public void testOnlyFile() throws Exception
+ public void testFieldDeferred() throws Exception
+ {
+ String name = "field";
+ byte[] data = "Hello, World".getBytes(StandardCharsets.US_ASCII);
+ start(new AbstractMultiPartHandler()
+ {
+ @Override
+ protected void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ Collection<Part> parts = request.getParts();
+ Assert.assertEquals(1, parts.size());
+ Part part = parts.iterator().next();
+ Assert.assertEquals(name, part.getName());
+ Assert.assertEquals("text/plain", part.getContentType());
+ Assert.assertArrayEquals(data, IO.readBytes(part.getInputStream()));
+ }
+ });
+
+ MultiPartContentProvider multiPart = new MultiPartContentProvider();
+ DeferredContentProvider content = new DeferredContentProvider();
+ multiPart.addFieldPart(name, content, null);
+ CountDownLatch responseLatch = new CountDownLatch(1);
+ client.newRequest("localhost", connector.getLocalPort())
+ .scheme(scheme)
+ .method(HttpMethod.POST)
+ .content(multiPart)
+ .send(result ->
+ {
+ if (result.isSucceeded())
+ {
+ Assert.assertEquals(200, result.getResponse().getStatus());
+ responseLatch.countDown();
+ }
+ });
+
+ // Wait until the request has been sent.
+ Thread.sleep(1000);
+
+ // Provide the content.
+ content.offer(ByteBuffer.wrap(data));
+ content.close();
+
+ Assert.assertTrue(responseLatch.await(5, TimeUnit.SECONDS));
+ }
+
+ @Test
+ public void testFileFromInputStream() throws Exception
+ {
+ String name = "file";
+ String fileName = "upload.png";
+ String contentType = "image/png";
+ byte[] data = new byte[512];
+ new Random().nextBytes(data);
+ start(new AbstractMultiPartHandler()
+ {
+ @Override
+ protected void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ Collection<Part> parts = request.getParts();
+ Assert.assertEquals(1, parts.size());
+ Part part = parts.iterator().next();
+ Assert.assertEquals(name, part.getName());
+ Assert.assertEquals(contentType, part.getContentType());
+ Assert.assertEquals(fileName, part.getSubmittedFileName());
+ Assert.assertEquals(data.length, part.getSize());
+ Assert.assertArrayEquals(data, IO.readBytes(part.getInputStream()));
+ }
+ });
+
+ CountDownLatch closeLatch = new CountDownLatch(1);
+ MultiPartContentProvider multiPart = new MultiPartContentProvider();
+ InputStreamContentProvider content = new InputStreamContentProvider(new ByteArrayInputStream(data)
+ {
+ @Override
+ public void close() throws IOException
+ {
+ super.close();
+ closeLatch.countDown();
+ }
+ });
+ HttpFields fields = new HttpFields();
+ fields.put(HttpHeader.CONTENT_TYPE, contentType);
+ multiPart.addFilePart(name, fileName, content, fields);
+ ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
+ .scheme(scheme)
+ .method(HttpMethod.POST)
+ .content(multiPart)
+ .send();
+
+ Assert.assertTrue(closeLatch.await(5, TimeUnit.SECONDS));
+ Assert.assertEquals(200, response.getStatus());
+ }
+
+ @Test
+ public void testFileFromPath() throws Exception
{
// Prepare a file to upload.
String data = "multipart_test_\u20ac";
@@ -176,7 +279,8 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
});
MultiPartContentProvider multiPart = new MultiPartContentProvider();
- multiPart.addPart(new MultiPartContentProvider.PathPart(name, tmpPath, contentType));
+ ContentProvider content = new PathContentProvider(contentType, tmpPath);
+ multiPart.addFilePart(name, tmpPath.getFileName().toString(), content, null);
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
.method(HttpMethod.POST)
@@ -205,7 +309,7 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
String value = "\u20ac";
String fileField = "file";
Charset encoding = StandardCharsets.UTF_8;
- String contentType = "text/plain; charset=" + encoding.name();
+ String contentType = "text/plain;charset=" + encoding.name();
String headerName = "foo";
String headerValue = "bar";
start(new AbstractMultiPartHandler()
@@ -238,11 +342,10 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
});
MultiPartContentProvider multiPart = new MultiPartContentProvider();
- Fields fields = new Fields();
- fields.put("Content-Type", contentType);
+ HttpFields fields = new HttpFields();
fields.put(headerName, headerValue);
- multiPart.addPart(new MultiPartContentProvider.FieldPart(field, encoding.encode(value), fields));
- multiPart.addPart(new MultiPartContentProvider.PathPart(fileField, tmpPath));
+ multiPart.addFieldPart(field, new StringContentProvider(value, encoding), fields);
+ multiPart.addFilePart(fileField, tmpPath.getFileName().toString(), new PathContentProvider(tmpPath), null);
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
.method(HttpMethod.POST)
@@ -254,6 +357,72 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
Files.delete(tmpPath);
}
+ @Test
+ public void testFieldDeferredAndFileDeferred() throws Exception
+ {
+ String value = "text";
+ Charset encoding = StandardCharsets.US_ASCII;
+ byte[] fileData = new byte[1024];
+ new Random().nextBytes(fileData);
+ start(new AbstractMultiPartHandler()
+ {
+ @Override
+ protected void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ List<Part> parts = new ArrayList<>(request.getParts());
+ Assert.assertEquals(2, parts.size());
+ Part fieldPart = parts.get(0);
+ Part filePart = parts.get(1);
+ if (!"field".equals(fieldPart.getName()))
+ {
+ Part swap = filePart;
+ filePart = fieldPart;
+ fieldPart = swap;
+ }
+
+ Assert.assertEquals(value, IO.toString(fieldPart.getInputStream(), encoding));
+
+ Assert.assertEquals("file", filePart.getName());
+ Assert.assertEquals("application/octet-stream", filePart.getContentType());
+ Assert.assertEquals("fileName", filePart.getSubmittedFileName());
+ Assert.assertArrayEquals(fileData, IO.readBytes(filePart.getInputStream()));
+ }
+ });
+
+ MultiPartContentProvider multiPart = new MultiPartContentProvider();
+ DeferredContentProvider fieldContent = new DeferredContentProvider();
+ multiPart.addFieldPart("field", fieldContent, null);
+ DeferredContentProvider fileContent = new DeferredContentProvider();
+ multiPart.addFilePart("file", "fileName", fileContent, null);
+ CountDownLatch responseLatch = new CountDownLatch(1);
+ client.newRequest("localhost", connector.getLocalPort())
+ .scheme(scheme)
+ .method(HttpMethod.POST)
+ .content(multiPart)
+ .send(result ->
+ {
+ if (result.isSucceeded())
+ {
+ Assert.assertEquals(200, result.getResponse().getStatus());
+ responseLatch.countDown();
+ }
+ });
+
+ // Wait until the request has been sent.
+ Thread.sleep(1000);
+
+ // Provide the content, in reversed part order.
+ fileContent.offer(ByteBuffer.wrap(fileData));
+ fileContent.close();
+
+ Thread.sleep(1000);
+
+ fieldContent.offer(encoding.encode(value));
+ fieldContent.close();
+
+ Assert.assertTrue(responseLatch.await(5, TimeUnit.SECONDS));
+ }
+
private static abstract class AbstractMultiPartHandler extends AbstractHandler
{
@Override
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java
index 4088d95d39..1037b3bd65 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java
@@ -695,6 +695,10 @@ public class PushCacheFilterTest extends AbstractTest
@Override
public Stream.Listener onPush(Stream stream, PushPromiseFrame frame)
{
+ MetaData metaData = frame.getMetaData();
+ Assert.assertTrue(metaData instanceof MetaData.Request);
+ MetaData.Request pushedRequest = (MetaData.Request)metaData;
+ Assert.assertEquals(servletPath + secondaryResource, pushedRequest.getURI().getPathQuery());
return new Adapter()
{
@Override
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
index 402ad48243..caa79c57a9 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
@@ -443,6 +443,9 @@ public abstract class AbstractJettyMojo extends AbstractMojo
//set up a RequestLog if one is provided and the handle structure
ServerSupport.configureHandlers(server, this.requestLog);
+
+ //Set up list of default Configurations to apply to a webapp
+ ServerSupport.configureDefaultConfigurationClasses(server);
configureWebApplication();
ServerSupport.addWebApplication(server, webApp);
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
index d4ac65e2ac..22cf2f21dc 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
@@ -244,6 +244,8 @@ public class JettyRunForkedMojo extends JettyRunMojo
//ensure handler structure enabled
ServerSupport.configureHandlers(server, null);
+
+ ServerSupport.configureDefaultConfigurationClasses(server);
//ensure config of the webapp based on settings in plugin
configureWebApplication();
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
index 8f1f343584..0a2dd8cc3b 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
@@ -72,23 +72,25 @@ public class JettyWebAppContext extends WebAppContext
private static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN = ".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$|.*javax.servlet.jsp.jstl-[^/]*\\.jar|.*taglibs-standard-impl-.*\\.jar";
private static final String WEB_INF_CLASSES_PREFIX = "/WEB-INF/classes";
private static final String WEB_INF_LIB_PREFIX = "/WEB-INF/lib";
+
+
+ public static final String[] DEFAULT_CONFIGURATION_CLASSES = {
+ "org.eclipse.jetty.maven.plugin.MavenWebInfConfiguration",
+ "org.eclipse.jetty.webapp.WebXmlConfiguration",
+ "org.eclipse.jetty.webapp.MetaInfConfiguration",
+ "org.eclipse.jetty.webapp.FragmentConfiguration",
+ "org.eclipse.jetty.plus.webapp.EnvConfiguration",
+ "org.eclipse.jetty.plus.webapp.PlusConfiguration",
+ "org.eclipse.jetty.annotations.AnnotationConfiguration",
+ "org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
+ };
- private final Configuration[] _defaultConfigurations = {
- new MavenWebInfConfiguration(),
- new WebXmlConfiguration(),
- new MetaInfConfiguration(),
- new FragmentConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new AnnotationConfiguration(),
- new JettyWebXmlConfiguration()
- };
- private final Configuration[] _quickStartConfigurations = {
- new MavenQuickStartConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new JettyWebXmlConfiguration()
+ private final String[] QUICKSTART_CONFIGURATION_CLASSES = {
+ "org.eclipse.jetty.maven.plugin.MavenQuickStartConfiguration",
+ "org.eclipse.jetty.plus.webapp.EnvConfiguration",
+ "org.eclipse.jetty.plus.webapp.PlusConfiguration",
+ "org.eclipse.jetty.webapp.JettyWebXmlConfiguration"
};
private File _classes = null;
@@ -100,6 +102,7 @@ public class JettyWebAppContext extends WebAppContext
private String _jettyEnvXml;
private List<Overlay> _overlays;
private Resource _quickStartWebXml;
+
@@ -338,25 +341,17 @@ public class JettyWebAppContext extends WebAppContext
{
//choose if this will be a quickstart or normal start
if (!isGenerateQuickStart() && getQuickStartWebDescriptor() != null)
- setConfigurations(_quickStartConfigurations);
- else
{
- setConfigurations(_defaultConfigurations);
+ setConfigurationClasses(QUICKSTART_CONFIGURATION_CLASSES);
+ }
+ else
+ {
if (isGenerateQuickStart())
{
_preconfigProcessor = new PreconfigureDescriptorProcessor();
getMetaData().addDescriptorProcessor(_preconfigProcessor);
}
}
-
- //inject configurations with config from maven plugin
- for (Configuration c:getConfigurations())
- {
- if (c instanceof EnvConfiguration && getJettyEnvXml() != null)
- ((EnvConfiguration)c).setJettyEnvXml(Resource.toURL(new File(getJettyEnvXml())));
- else if (c instanceof MavenQuickStartConfiguration && getQuickStartWebDescriptor() != null)
- ((MavenQuickStartConfiguration)c).setQuickStartWebXml(getQuickStartWebDescriptor());
- }
//Set up the pattern that tells us where the jars are that need scanning
@@ -404,6 +399,22 @@ public class JettyWebAppContext extends WebAppContext
}
+ @Override
+ protected void loadConfigurations() throws Exception
+ {
+ super.loadConfigurations();
+
+ //inject configurations with config from maven plugin
+ for (Configuration c:getConfigurations())
+ {
+ if (c instanceof EnvConfiguration && getJettyEnvXml() != null)
+ ((EnvConfiguration)c).setJettyEnvXml(Resource.toURL(new File(getJettyEnvXml())));
+ else if (c instanceof MavenQuickStartConfiguration && getQuickStartWebDescriptor() != null)
+ ((MavenQuickStartConfiguration)c).setQuickStartWebXml(getQuickStartWebDescriptor());
+ }
+ }
+
+
/* ------------------------------------------------------------ */
public void doStop () throws Exception
{
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
index babfe6830a..407a17f2a9 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
@@ -35,6 +35,7 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.RequestLogHandler;
import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration;
@@ -46,6 +47,13 @@ import org.eclipse.jetty.xml.XmlConfiguration;
*/
public class ServerSupport
{
+
+ public static void configureDefaultConfigurationClasses (Server server)
+ {
+ server.setAttribute(Configuration.ATTR, JettyWebAppContext.DEFAULT_CONFIGURATION_CLASSES);
+ }
+
+
/**
* Set up the handler structure to receive a webapp.
* Also put in a DefaultHandler so we get a nice page
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
index 0f9e361cbd..a5b94536ad 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
@@ -125,7 +125,10 @@ public class Starter
//check if contexts already configured, create if not
ServerSupport.configureHandlers(server, null);
-
+
+ //Set up list of default Configurations to apply to a webapp
+ ServerSupport.configureDefaultConfigurationClasses(server);
+
webApp = new JettyWebAppContext();
//configure webapp from properties file describing unassembled webapp
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilder.java b/jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilder.java
index 2dbbb2f1d7..a16c9960e6 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilder.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilder.java
@@ -29,7 +29,8 @@ import javax.servlet.http.HttpSession;
/** Build a request to be pushed.
*
* <p>A PushBuilder is obtained by calling {@link
- * HttpServletRequest#getPushBuilder()}. Each call to this method will
+ * Request#getPushBuilder()} (<code>Eventually HttpServletRequest.getPushBuilder()</code>).
+ * Each call to this method will
* return a new instance of a PushBuilder based off the current {@code
* HttpServletRequest}. Any mutations to the returned PushBuilder are
* not reflected on future returns.</p>
@@ -103,12 +104,10 @@ public interface PushBuilder
*
* <p>Any non-empty String may be used for the method.</p>
*
- * @throws NullPointerException if the argument is {@code null}
- *
- * @throws IllegalArgumentException if the argument is the empty String
- *
* @param method the method to be used for the push.
* @return this builder.
+ * @throws NullPointerException if the argument is {@code null}
+ * @throws IllegalArgumentException if the argument is the empty String
*/
public abstract PushBuilder method(String method);
@@ -209,7 +208,7 @@ public interface PushBuilder
* nulled after every call to {@link #push()}
* @param lastModified the last modified date to be used for the push.
* @return this builder.
- * */
+ */
public abstract PushBuilder lastModified(String lastModified);
@@ -240,10 +239,6 @@ public interface PushBuilder
*/
public abstract void push();
-
-
-
-
public abstract String getMethod();
public abstract String getQueryString();
public abstract String getSessionId();
@@ -253,8 +248,4 @@ public interface PushBuilder
public abstract String getPath();
public abstract String getEtag();
public abstract String getLastModified();
-
-
-
-
} \ No newline at end of file
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilderImpl.java b/jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilderImpl.java
index d2f30f3d7c..def6bed888 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilderImpl.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilderImpl.java
@@ -32,14 +32,14 @@ import org.eclipse.jetty.util.log.Logger;
/* ------------------------------------------------------------ */
-/**
+/**
*/
public class PushBuilderImpl implements PushBuilder
-{
+{
private static final Logger LOG = Log.getLogger(PushBuilderImpl.class);
private final static HttpField JettyPush = new HttpField("x-http2-push","PushBuilder");
-
+
private final Request _request;
private final HttpFields _fields;
private String _method;
@@ -49,7 +49,7 @@ public class PushBuilderImpl implements PushBuilder
private String _path;
private String _etag;
private String _lastModified;
-
+
public PushBuilderImpl(Request request, HttpFields fields, String method, String queryString, String sessionId, boolean conditional)
{
super();
@@ -70,7 +70,7 @@ public class PushBuilderImpl implements PushBuilder
{
return _method;
}
-
+
/* ------------------------------------------------------------ */
@Override
public PushBuilder method(String method)
@@ -78,14 +78,14 @@ public class PushBuilderImpl implements PushBuilder
_method = method;
return this;
}
-
+
/* ------------------------------------------------------------ */
@Override
public String getQueryString()
{
return _queryString;
}
-
+
/* ------------------------------------------------------------ */
@Override
public PushBuilder queryString(String queryString)
@@ -93,14 +93,14 @@ public class PushBuilderImpl implements PushBuilder
_queryString = queryString;
return this;
}
-
+
/* ------------------------------------------------------------ */
@Override
public String getSessionId()
{
return _sessionId;
}
-
+
/* ------------------------------------------------------------ */
@Override
public PushBuilder sessionId(String sessionId)
@@ -108,14 +108,14 @@ public class PushBuilderImpl implements PushBuilder
_sessionId = sessionId;
return this;
}
-
+
/* ------------------------------------------------------------ */
@Override
public boolean isConditional()
{
return _conditional;
}
-
+
/* ------------------------------------------------------------ */
@Override
public PushBuilder conditional(boolean conditional)
@@ -123,21 +123,21 @@ public class PushBuilderImpl implements PushBuilder
_conditional = conditional;
return this;
}
-
+
/* ------------------------------------------------------------ */
@Override
public Set<String> getHeaderNames()
{
return _fields.getFieldNamesCollection();
}
-
+
/* ------------------------------------------------------------ */
@Override
public String getHeader(String name)
{
return _fields.get(name);
}
-
+
/* ------------------------------------------------------------ */
@Override
public PushBuilder setHeader(String name,String value)
@@ -145,7 +145,7 @@ public class PushBuilderImpl implements PushBuilder
_fields.put(name,value);
return this;
}
-
+
/* ------------------------------------------------------------ */
@Override
public PushBuilder addHeader(String name,String value)
@@ -161,7 +161,7 @@ public class PushBuilderImpl implements PushBuilder
_fields.remove(name);
return this;
}
-
+
/* ------------------------------------------------------------ */
@Override
public String getPath()
@@ -213,31 +213,31 @@ public class PushBuilderImpl implements PushBuilder
{
if (HttpMethod.POST.is(_method) || HttpMethod.PUT.is(_method))
throw new IllegalStateException("Bad Method "+_method);
-
+
if (_path==null || _path.length()==0)
throw new IllegalStateException("Bad Path "+_path);
-
+
String path=_path;
String query=_queryString;
int q=path.indexOf('?');
if (q>=0)
{
- query=(query!=null && query.length()>0)?(_path.substring(q+1)+'&'+query):_path.substring(q+1);
- path=_path.substring(0,q);
+ query=(query!=null && query.length()>0)?(path.substring(q+1)+'&'+query):path.substring(q+1);
+ path=path.substring(0,q);
}
-
+
if (!path.startsWith("/"))
path=URIUtil.addPaths(_request.getContextPath(),path);
-
+
String param=null;
if (_sessionId!=null)
{
if (_request.isRequestedSessionIdFromURL())
param="jsessionid="+_sessionId;
- // TODO else
+ // TODO else
// _fields.add("Cookie","JSESSIONID="+_sessionId);
}
-
+
if (_conditional)
{
if (_etag!=null)
@@ -245,13 +245,13 @@ public class PushBuilderImpl implements PushBuilder
else if (_lastModified!=null)
_fields.add(HttpHeader.IF_MODIFIED_SINCE,_lastModified);
}
-
- HttpURI uri = HttpURI.createHttpURI(_request.getScheme(),_request.getServerName(),_request.getServerPort(),_path,param,query,null);
+
+ HttpURI uri = HttpURI.createHttpURI(_request.getScheme(),_request.getServerName(),_request.getServerPort(),path,param,query,null);
MetaData.Request push = new MetaData.Request(_method,uri,_request.getHttpVersion(),_fields);
-
+
if (LOG.isDebugEnabled())
LOG.debug("Push {} {} inm={} ims={}",_method,uri,_fields.get(HttpHeader.IF_NONE_MATCH),_fields.get(HttpHeader.IF_MODIFIED_SINCE));
-
+
_request.getHttpChannel().getHttpTransport().push(push);
_path=null;
_etag=null;
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java
index bd1247f03e..ae10b7d872 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java
@@ -69,8 +69,8 @@ public class ServletMapping
/* ------------------------------------------------------------ */
/** Test if the list of path specs contains a particular one.
- * @param pathSpec
- * @return
+ * @param pathSpec the path spec
+ * @return true if path spec matches something in mappings
*/
public boolean containsPathSpec (String pathSpec)
{
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
index aa6e66be2f..544c392a9c 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
@@ -34,7 +34,6 @@ import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
-import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@@ -45,7 +44,6 @@ import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersion;
-import org.eclipse.jetty.server.Dispatcher;
import org.eclipse.jetty.server.PushBuilder;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.StringUtil;
@@ -158,6 +156,9 @@ public class PushCacheFilter implements Filter
LOG.debug("{} {} referrer={} conditional={}", request.getMethod(), request.getRequestURI(), referrer, conditional);
String path = URIUtil.addPaths(request.getServletPath(), request.getPathInfo());
+ String query = request.getQueryString();
+ if (query != null)
+ path += "?" + query;
if (referrer != null)
{
HttpURI referrerURI = new HttpURI(referrer);
@@ -254,12 +255,12 @@ public class PushCacheFilter implements Filter
if (!conditional && !primaryResource._associated.isEmpty())
{
PushBuilder builder = Request.getBaseRequest(request).getPushBuilder();
-
+
for (String associated : primaryResource._associated.values())
{
if (LOG.isDebugEnabled())
LOG.debug("Pushing {} for {}", associated, path);
-
+
builder.path(associated).push();
}
}

Back to the top