Skip to content

Commit

Permalink
Merge pull request #1309 from eikek/response-headers
Browse files Browse the repository at this point in the history
Don't set content-length with transfer-encoding:chunked in responses
  • Loading branch information
mergify[bot] authored Jan 22, 2024
2 parents 79abc78 + 5847b18 commit c3dde5f
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ object ByteResponse {
file <- backend.share.loadFile(shareId, fid, pass, ByteRange.All)
resp <- OptionT.liftF(
etagResponse(dsl, req, file).getOrElseF(
Ok(file.data)
Ok.apply(file.data)
.map(setETag(file.fileMeta))
.map(
_.putHeaders(
`Content-Type`(mediaType(file)),
`Accept-Ranges`.bytes,
`Last-Modified`(timestamp(file)),
`Content-Disposition`("inline", fileNameMap(file)),
`Content-Length`.unsafeFromLong(file.fileMeta.length.bytes)
fileSizeHeader(file.fileMeta.length)
)
)
)
Expand Down Expand Up @@ -118,7 +118,7 @@ object ByteResponse {
`Content-Type`(mediaType(file)),
`Last-Modified`(timestamp(file)),
`Content-Disposition`("inline", fileNameMap(file)),
`Content-Length`.unsafeFromLong(respLen),
fileSizeHeader(ByteSize(respLen)),
`Content-Range`(RangeUnit.Bytes, subRangeResp(range, len.bytes), Some(len.bytes))
)
)
Expand All @@ -143,4 +143,7 @@ object ByteResponse {

private def fileNameMap[F[_]](file: FileRange[F]) =
file.shareFile.filename.map(n => Map(CIString("filename") -> n)).getOrElse(Map.empty)

private def fileSizeHeader(sz: ByteSize) =
Header.Raw(CIString("File-Size"), sz.bytes.toString)
}

0 comments on commit c3dde5f

Please sign in to comment.