Skip to content

Commit

Permalink
work-around a possible bug (or, at least, undesirable behavior0) in C…
Browse files Browse the repository at this point in the history
…XF when the lastModified date is EQUAL to the if-modified-since header.
  • Loading branch information
cbeer committed Mar 9, 2013
1 parent 1c2dd50 commit f440564
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Expand Up @@ -363,8 +363,9 @@ public Response getDatastreamContent(@PathParam("pid")

EntityTag etag = new EntityTag(ds.getContentDigest().toString());
Date date = ds.getLastModifiedDate();
ResponseBuilder builder = request.evaluatePreconditions(date, etag);
// ResponseBuilder builder = request.evaluatePreconditions(date, etag);

ResponseBuilder builder = request.evaluatePreconditions(etag);

CacheControl cc = new CacheControl();
cc.setMaxAge(0);
Expand Down
Expand Up @@ -3,6 +3,7 @@

import static java.util.regex.Pattern.DOTALL;
import static java.util.regex.Pattern.compile;
import static junit.framework.Assert.format;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Expand All @@ -20,6 +21,9 @@
import org.apache.http.util.EntityUtils;
import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.Date;

public class FedoraDatastreamsTest extends AbstractResourceTest {

private static final String faulkner1 =
Expand Down Expand Up @@ -127,9 +131,37 @@ public void testGetDatastreamContent() throws Exception {

assertEquals("ETag: \"urn:sha1:ba6cb22191300aebcfcfb83de9635d6b224677df\"", response.getFirstHeader("ETag").toString());



logger.debug("Content was correct.");
}

@Test
public void testRefetchingDatastreamContent() throws Exception {

final HttpPost createObjMethod =
postObjMethod("FedoraDatastreamsTest61");
assertEquals(201, getStatus(createObjMethod));

final HttpPost createDSMethod =
postDSMethod("FedoraDatastreamsTest61", "ds1",
"marbles for everyone");
assertEquals(201, getStatus(createDSMethod));


SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");


final HttpGet method_test_get =
new HttpGet(serverAddress +
"objects/FedoraDatastreamsTest61/datastreams/ds1/content");
method_test_get.setHeader("If-None-Match","\"urn:sha1:ba6cb22191300aebcfcfb83de9635d6b224677df\"");
method_test_get.setHeader("If-Modified-Since", format.format(new Date()));

assertEquals(304, getStatus(method_test_get));

}

@Test
public void testMultipleDatastreams() throws Exception {
final HttpPost createObjMethod =
Expand Down

0 comments on commit f440564

Please sign in to comment.