Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request body gzip compression #1918

Open
nikola-mladenovic opened this issue Aug 7, 2023 · 2 comments · May be fixed by #2381
Open

Request body gzip compression #1918

nikola-mladenovic opened this issue Aug 7, 2023 · 2 comments · May be fixed by #2381

Comments

@nikola-mladenovic
Copy link

Hi,

Do you have a built-in mechanism for gzip compressing request body? So far I've tried the following:

def gzipCompressBytes(dataBytes: Array[Byte]): Array[Byte] = {
  val baos = new ByteArrayOutputStream
  val gzos = new GZIPOutputStream(baos)
  gzos.write(dataBytes)
  gzos.finish()
  gzos.close()
  baos.close()
  baos.toByteArray
}

val body: JValue = JArray(objs.toList)
val compressedBody = gzipCompressBytes(body.show.getBytes())

val baseRequest = basicRequest
 .header(ContentEncoding, "gzip")
 .header(ContentType, "application/json")
 .body(compressedBody)
 .header("accept", "application/json")

However this approach didn't seem to work - is there any recommendation from your end how to achieve request body compression? Thanks! 🙏

@adamw
Copy link
Member

adamw commented Aug 17, 2023

So far there's no built-in mechanism, but you are right that this is a good candidate for a feature (just as we have auto-decompression).

Until this is done, your "manual" approach looks fine. I tested it with https://postman-echo.com/post and got back correct results. Can you describe what problems do you encounter, and which backend you are using?

iyfedorov pushed a commit to iyfedorov/sttp that referenced this issue Apr 23, 2024
iyfedorov pushed a commit to iyfedorov/sttp that referenced this issue Apr 23, 2024
@iyfedorov
Copy link

#2148

iyfedorov pushed a commit to iyfedorov/sttp that referenced this issue Apr 26, 2024
@adamw adamw linked a pull request Dec 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants