Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-11-05 02:41:25 -0500
committerGreg Wilkins2015-11-05 02:41:25 -0500
commited2550b50f978e1984e19fbda642baf450dbe6a1 (patch)
treec6940a2061d4b2b98415054ae8aa0ffda3ca290e
parent88d7b35f885de2da7dec836e6e4ae2b522d517f0 (diff)
parentde137abcc7802e93fc61f6db25ffec775fd870b5 (diff)
downloadorg.eclipse.jetty.project-ed2550b50f978e1984e19fbda642baf450dbe6a1.tar.gz
org.eclipse.jetty.project-ed2550b50f978e1984e19fbda642baf450dbe6a1.tar.xz
org.eclipse.jetty.project-ed2550b50f978e1984e19fbda642baf450dbe6a1.zip
Merge branch 'master' into unix-socket
-rw-r--r--examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java3
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java21
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java3
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java2
5 files changed, 28 insertions, 5 deletions
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java
index 8d984bf2d1..8e19c0a20e 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java
@@ -55,6 +55,7 @@ import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.servlets.PushCacheFilter;
import org.eclipse.jetty.servlets.PushSessionCacheFilter;
import org.eclipse.jetty.util.ssl.SslContextFactory;
@@ -74,7 +75,8 @@ public class Http2Server
ServletContextHandler context = new ServletContextHandler(server, "/",ServletContextHandler.SESSIONS);
context.setResourceBase("src/main/resources/docroot");
- context.addFilter(PushSessionCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
+ context.addFilter(PushCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
+ // context.addFilter(PushSessionCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
context.addFilter(PushedTilesFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
context.addServlet(new ServletHolder(servlet), "/test/*");
context.addServlet(DefaultServlet.class, "/").setInitParameter("maxCacheSize","81920");
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java
index 6a38a710a8..9c2a72ab59 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java
@@ -498,11 +498,12 @@ public class ResourceHandler extends HandlerWrapper
doResponseHeaders(response,resource,mime);
if (_etags)
baseRequest.getResponse().getHttpFields().put(HttpHeader.ETAG,etag);
+ if (last_modified>0)
+ response.setDateHeader(HttpHeader.LAST_MODIFIED.asString(),last_modified);
if(skipContentBody)
return;
-
// Send the content
OutputStream out =null;
try {out = response.getOutputStream();}
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java
index 7101ad4ed5..22d28d72d3 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java
@@ -18,6 +18,9 @@
package org.eclipse.jetty.server.handler;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertThat;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -33,6 +36,7 @@ import java.nio.file.Files;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
@@ -58,6 +62,7 @@ public class ResourceHandlerTest
private static Server _server;
private static HttpConfiguration _config;
private static ServerConnector _connector;
+ private static LocalConnector _local;
private static ContextHandler _contextHandler;
private static ResourceHandler _resourceHandler;
@@ -111,7 +116,9 @@ public class ResourceHandlerTest
_config.setOutputBufferSize(2048);
_connector = new ServerConnector(_server,new HttpConnectionFactory(_config));
- _server.setConnectors(new Connector[] { _connector });
+ _local = new LocalConnector(_server);
+
+ _server.setConnectors(new Connector[] { _connector, _local });
_resourceHandler = new ResourceHandler();
_resourceHandler.setMinAsyncContentLength(4096);
@@ -152,6 +159,18 @@ public class ResourceHandlerTest
}
@Test
+ public void testHeaders() throws Exception
+ {
+ String response = _local.getResponses("GET /resource/simple.txt HTTP/1.0\r\n\r\n");
+ assertThat(response,startsWith("HTTP/1.1 200 OK"));
+ assertThat(response,Matchers.containsString("Content-Type: text/plain"));
+ assertThat(response,Matchers.containsString("Last-Modified: "));
+ assertThat(response,Matchers.containsString("Content-Length: 11"));
+ assertThat(response,Matchers.containsString("Server: Jetty"));
+ assertThat(response,Matchers.containsString("simple text"));
+ }
+
+ @Test
public void testBigFile() throws Exception
{
_config.setOutputBufferSize(2048);
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
index f899d9809e..534d1076a1 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
@@ -125,7 +125,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"org.eclipse.jetty.util.log.", // webapp should use server log
"org.eclipse.jetty.servlet.DefaultServlet", // webapp cannot change default servlets
"org.eclipse.jetty.jsp.JettyJspServlet", //webapp cannot change jetty jsp servlet
- "org.eclipse.jetty.servlets.PushCacheFilter" //must be loaded by container classpath
+ "org.eclipse.jetty.servlets.PushCacheFilter", //must be loaded by container classpath
+ "org.eclipse.jetty.servlets.PushSessionCacheFilter" //must be loaded by container classpath
} ;
// Server classes are classes that are hidden from being
diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java
index 6887c10b32..3a6b918239 100644
--- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java
+++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/Dump.java
@@ -118,7 +118,7 @@ public class Dump extends HttpServlet
}
catch(ServletException se)
{
- se.printStackTrace();
+ getServletContext().log(se.toString());
}
}

Back to the top