Skip to content

Commit

Permalink
URLConnection.getHeaderField - The the last-modified format and retur…
Browse files Browse the repository at this point in the history
…n null if the header does not exist
  • Loading branch information
tpunder committed Sep 6, 2019
1 parent 3c74308 commit 5f6520e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/scala/fm/sbt/s3/S3URLConnection.scala
Expand Up @@ -5,6 +5,8 @@ import com.amazonaws.services.s3.model.{ObjectMetadata, S3Object}
import fm.sbt.S3URLHandler
import java.io.InputStream
import java.net.{HttpURLConnection, URL}
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter

object S3URLConnection {
private val s3: S3URLHandler = new S3URLHandler()
Expand Down Expand Up @@ -80,8 +82,8 @@ final class S3URLConnection(url: URL) extends HttpURLConnection(url) {
case "content-type" => response.map{ _.meta.getContentType }.orNull
case "content-encoding" => response.map{ _.meta.getContentEncoding }.orNull
case "content-length" => response.map{ _.meta.getContentLength().toString }.orNull
case "last-modified" => response.map{ _.meta.getLastModified.getTime.toString }.orNull
case _ => ""
case "last-modified" => response.map{ _.meta.getLastModified }.map{ _.toInstant.atOffset(ZoneOffset.UTC) }.map{ DateTimeFormatter.RFC_1123_DATE_TIME.format }.orNull
case _ => null // Should return null if no value for header
}
}

Expand Down

0 comments on commit 5f6520e

Please sign in to comment.