HDDS-678. Format of Last-Modified header is invalid in HEAD Object call. Contributed by Elek Marton.
This commit is contained in:
parent
9146d33e18
commit
3ed7163302
|
@ -34,6 +34,10 @@ import javax.ws.rs.core.Response.Status;
|
|||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -180,8 +184,13 @@ public class ObjectEndpoint extends EndpointBase {
|
|||
}
|
||||
}
|
||||
|
||||
ZonedDateTime lastModificationTime =
|
||||
Instant.ofEpochMilli(key.getModificationTime())
|
||||
.atZone(ZoneId.of("GMT"));
|
||||
|
||||
return Response.ok().status(HttpStatus.SC_OK)
|
||||
.header("Last-Modified", key.getModificationTime())
|
||||
.header("Last-Modified",
|
||||
DateTimeFormatter.RFC_1123_DATE_TIME.format(lastModificationTime))
|
||||
.header("ETag", "" + key.getModificationTime())
|
||||
.header("Content-Length", key.getDataSize())
|
||||
.header("Content-Type", "binary/octet-stream")
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.hadoop.ozone.s3.endpoint;
|
|||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.apache.hadoop.hdds.client.ReplicationFactor;
|
||||
import org.apache.hadoop.hdds.client.ReplicationType;
|
||||
|
@ -80,6 +81,10 @@ public class TestObjectHead {
|
|||
Assert.assertEquals(200, response.getStatus());
|
||||
Assert.assertEquals(value.getBytes().length,
|
||||
Long.parseLong(response.getHeaderString("Content-Length")));
|
||||
|
||||
DateTimeFormatter.RFC_1123_DATE_TIME
|
||||
.parse(response.getHeaderString("Last-Modified"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue