Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Add endpoint for HEAD request to s3-encrypted
Browse files Browse the repository at this point in the history
  • Loading branch information
MalinAhlberg committed Feb 14, 2024
1 parent 9c1b495 commit 8f1c5ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func Setup() *http.Server {
router.GET("/files/:fileid", SelectedMiddleware(), sda.Download)
router.GET("/s3/*path", SelectedMiddleware(), s3.Download)
router.HEAD("/s3/*path", SelectedMiddleware(), s3.Download)
router.HEAD("/s3-encrypted/*path", SelectedMiddleware(), s3.Download)
router.GET("/s3-encrypted/*path", SelectedMiddleware(), s3.Download)
router.GET("/health", healthResponse)

Expand Down
8 changes: 8 additions & 0 deletions api/sda/sda.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func Download(c *gin.Context) {
}

contentLength := fileDetails.DecryptedSize
log.Debug("decrypted size", fileDetails.DecryptedSize)
if c.Param("type") == "encrypted" {
end = calculateEncryptedEndPosition(start, end, fileDetails)
contentLength = int(end)
Expand Down Expand Up @@ -238,6 +239,13 @@ func Download(c *gin.Context) {

if c.Request.Method == http.MethodHead {

if c.Param("type") == "encrypted" {
// set the length of the crypt4gh header for htsget
c.Header("Server-Additional-Bytes", fmt.Sprint(bytes.NewReader(fileDetails.Header).Size()))
// TODO figure out if client crypt4gh header will have other size
// c.Header("Client-Additional-Bytes", ...)
}

return
}

Expand Down

0 comments on commit 8f1c5ce

Please sign in to comment.