Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-11-05 02:39:04 -0500
committerGreg Wilkins2015-11-05 02:39:04 -0500
commitfc9f42e11a0c2137fe82fb0fb9b9bdf2308a7d22 (patch)
tree1d30c9eabb2d8d63a8fa963dbc8ec88d6b107b69
parent3e2658a41b07ec2b455ea806f2ba6f8a3245f581 (diff)
parentbd8f0b2dbaeee5889f484c2420c7223313dd682b (diff)
downloadorg.eclipse.jetty.project-fc9f42e11a0c2137fe82fb0fb9b9bdf2308a7d22.tar.gz
org.eclipse.jetty.project-fc9f42e11a0c2137fe82fb0fb9b9bdf2308a7d22.tar.xz
org.eclipse.jetty.project-fc9f42e11a0c2137fe82fb0fb9b9bdf2308a7d22.zip
Merge remote-tracking branch 'origin/jetty-9.3.x'
-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
2 files changed, 22 insertions, 2 deletions
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);

Back to the top