diff --git a/src/main/java/dk/kb/netarchivesuite/solrwayback/memento/DatetimeNegotiation.java b/src/main/java/dk/kb/netarchivesuite/solrwayback/memento/DatetimeNegotiation.java index 7e053355..50b02f93 100644 --- a/src/main/java/dk/kb/netarchivesuite/solrwayback/memento/DatetimeNegotiation.java +++ b/src/main/java/dk/kb/netarchivesuite/solrwayback/memento/DatetimeNegotiation.java @@ -190,7 +190,8 @@ private static Response streamMementoFromNonRedirectingTimeGate(MementoDoc doc, } /** - * Streams the memento found for the timegate. + * Return the header with the 302 redirection location. Has no payload. + * * @param doc containing data from solr for accessing the memento in the WARC files. * @param metadata object which contains metadata on the memento. Including the additional headers. * @return a response containing correct memento headers and the memento as the response entity. @@ -199,9 +200,8 @@ private static Response streamMementoFromRedirectingTimeGate(MementoDoc doc, Mem if (PropertiesLoader.PLAYBACK_DISABLED){ return Response.noContent().replaceAll(metadata.getHttpHeaders()).build(); } else { - try { - ArcEntry mementoEntity = Facade.getArcEntry(doc.getSource_file_path(), doc.getSource_file_offset()); - ResponseBuilder entity = Response.status(302).entity(mementoEntity.getBinaryRaw()); + try { + ResponseBuilder entity = Response.status(302); addMementoHeadersToReponse(entity,metadata); return entity.build(); } catch (Exception e) { diff --git a/src/test/java/dk/kb/netarchivesuite/solrwayback/memento/DatetimeNegotiationTest.java b/src/test/java/dk/kb/netarchivesuite/solrwayback/memento/DatetimeNegotiationTest.java index 12bc023a..f338b533 100644 --- a/src/test/java/dk/kb/netarchivesuite/solrwayback/memento/DatetimeNegotiationTest.java +++ b/src/test/java/dk/kb/netarchivesuite/solrwayback/memento/DatetimeNegotiationTest.java @@ -69,7 +69,8 @@ public void tearDown() throws Exception { @Test public void testHeadersForPatternTwoPointTwo() throws Exception { - PropertiesLoader.PLAYBACK_DISABLED = true; + PropertiesLoader.PLAYBACK_DISABLED = true; //Must be disabled since playback needs warc files + PropertiesLoader.MEMENTO_REDIRECT = false; Response timeGate = DatetimeNegotiation.getMemento("http://kb.dk/", "Thu, 23 Mar 2019 14:05:57 GMT"); MultivaluedMap headers = timeGate.getHeaders(); @@ -87,7 +88,7 @@ public void testHeadersForPatternTwoPointTwo() throws Exception { @Test public void testHeadersForPatternTwoPointOne() throws Exception { - PropertiesLoader.PLAYBACK_DISABLED = true; + PropertiesLoader.PLAYBACK_DISABLED = false; // PropertiesLoader.MEMENTO_REDIRECT = true; Response timeGate = DatetimeNegotiation.getMemento("http://kb.dk/", "Thu, 23 Mar 2019 14:05:57 GMT"); @@ -97,7 +98,7 @@ public void testHeadersForPatternTwoPointOne() throws Exception { assertNotNull(headers.get("Location")); assertFalse(headers.containsKey("Memento-Datetime")); assertTrue(headers.get("Link").get(0).toString().contains("rel=\"original\"")); - assertEquals(0, headers.get("Content-Length").get(0)); + assertEquals("0", headers.get("Content-Length").get(0)); assertEquals("text/html;charset=UTF-8", headers.get("Content-Type").get(0)); }