Skip to content

Commit

Permalink
Fix flags
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Dec 27, 2024
1 parent bf690fd commit 07b7bbf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ class AkkaHttpBackend private (
val body = bodyFromAkka(
r.response,
responseMetadata,
wsFlow.map(Right(_)).getOrElse(Left(decodeAkkaResponse(hr, r.autoDecompressionDisabled)))
wsFlow.map(Right(_)).getOrElse(Left(decodeAkkaResponse(hr, r.autoDecompressionEnabled)))
)

body.map(client4.Response(_, code, statusText, headers, Nil, r.onlyMetadata))
}

// http://doc.akka.io/docs/akka-http/10.0.7/scala/http/common/de-coding.html
private def decodeAkkaResponse(response: HttpResponse, disableAutoDecompression: Boolean): HttpResponse =
if (!response.status.allowsEntity() || disableAutoDecompression) response
private def decodeAkkaResponse(response: HttpResponse, autoDecompressionEnabled: Boolean): HttpResponse =
if (!response.status.allowsEntity() || !autoDecompressionEnabled) response
else customEncodingHandler.orElse(EncodingHandler(standardEncoding)).apply(response -> response.encoding)

private def standardEncoding: (HttpResponse, HttpEncoding) => HttpResponse = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Http4sBackend[F[_]: ConcurrentEffect: ContextShift](
responseMetadata,
Left(
onFinalizeSignal(
decompressResponseBodyIfNotHead(r.method, response, r.autoDecompressionDisabled),
decompressResponseBodyIfNotHead(r.method, response, r.autoDecompressionEnabled),
signalBodyComplete
)
)
Expand Down Expand Up @@ -176,9 +176,9 @@ class Http4sBackend[F[_]: ConcurrentEffect: ContextShift](
private def decompressResponseBodyIfNotHead[T](
m: Method,
hr: http4s.Response[F],
disableAutoDecompression: Boolean
autoDecompressionEnabled: Boolean
): http4s.Response[F] =
if (m == Method.HEAD || disableAutoDecompression) hr else decompressResponseBody(hr)
if (m == Method.HEAD || !autoDecompressionEnabled) hr else decompressResponseBody(hr)

private def decompressResponseBody(hr: http4s.Response[F]): http4s.Response[F] = {
val body = hr.headers
Expand Down

0 comments on commit 07b7bbf

Please sign in to comment.