File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
core/src/test/scalajvm/sttp/client4/testing Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,25 @@ trait HttpTestExtensions[F[_]] extends AsyncFreeSpecLike { self: HttpTest[F] =>
234234 new String (decompressedBytes) shouldBe " I'm not compressed"
235235 }
236236 }
237+
238+ " should compress a file-based request body using gzip" in {
239+ val testFileContent = " test file content"
240+ withTemporaryFile(Some (testFileContent.getBytes())) { file =>
241+ val req = basicRequest
242+ .compressBody(Encodings .Gzip )
243+ .response(asByteArrayAlways)
244+ .post(uri " $endpoint/echo/exact " )
245+ .body(file)
246+ req.send(backend).toFuture().map { resp =>
247+ resp.code shouldBe StatusCode .Ok
248+
249+ val gzipInputStream = new GZIPInputStream (new ByteArrayInputStream (resp.body))
250+ val decompressedBytes = gzipInputStream.readAllBytes()
251+
252+ new String (decompressedBytes) shouldBe testFileContent
253+ }
254+ }
255+ }
237256 }
238257
239258 private def withTemporaryFile [T ](content : Option [Array [Byte ]])(f : File => Future [T ]): Future [T ] = {
You can’t perform that action at this time.
0 commit comments