Skip to content

Commit

Permalink
Remove explicit content length header (#5188)
Browse files Browse the repository at this point in the history
* Remove explicit content length header

---------

Co-authored-by: Simon Dumas <simon.dumas@epfl.ch>
  • Loading branch information
imsdu and Simon Dumas authored Oct 16, 2024
1 parent 7b723ce commit d90d9ee
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,6 @@ class FilesRoutesSpec
header("Content-Disposition").value.value() shouldEqual
s"""attachment; filename="=?UTF-8?B?${base64encode(id)}?=""""
response.asString shouldEqual content
val attr = attributes(id)
response.header[`Content-Length`].value shouldEqual `Content-Length`(attr.bytes)
response.expectConditionalCacheHeaders
response.headers should contain(varyHeader)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.epfl.bluebrain.nexus.delta.sdk.directives

import akka.http.scaladsl.model.headers.`Content-Length`
import akka.http.scaladsl.model.{ContentType, HttpHeader, StatusCode, StatusCodes}
import cats.effect.IO
import cats.syntax.all._
Expand Down Expand Up @@ -45,8 +44,7 @@ object FileResponse {
implicit def fileResponseMetadataHttpResponseFields: HttpResponseFields[Metadata] =
new HttpResponseFields[Metadata] {
override def statusFrom(value: Metadata): StatusCode = StatusCodes.OK
override def headersFrom(value: Metadata): Seq[HttpHeader] =
value.bytes.map { bytes => `Content-Length`(bytes) }.toSeq
override def headersFrom(value: Metadata): Seq[HttpHeader] = Seq.empty

override def entityTag(value: Metadata): Option[String] = value.etag
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ch.epfl.bluebrain.nexus.delta.sdk.directives

import akka.http.scaladsl.model.ContentTypes.`text/plain(UTF-8)`
import akka.http.scaladsl.model.MediaRanges.`*/*`
import akka.http.scaladsl.model.headers.{`Content-Length`, Accept}
import akka.http.scaladsl.model.headers.Accept
import akka.http.scaladsl.model.{ContentType, StatusCodes}
import akka.http.scaladsl.server.RouteConcatenation
import akka.stream.scaladsl.Source
Expand Down Expand Up @@ -73,7 +73,6 @@ class ResponseToJsonLdSpec extends CatsEffectSpec with RouteHelpers with JsonSyn
status shouldEqual StatusCodes.OK
contentType shouldEqual `text/plain(UTF-8)`
response.asString shouldEqual FileContents
response.header[`Content-Length`].value shouldEqual `Content-Length`(1024L)
response.expectConditionalCacheHeaders
}
}
Expand Down

0 comments on commit d90d9ee

Please sign in to comment.