Skip to content

Commit

Permalink
Implementation of reported remarks + adding example of command output…
Browse files Browse the repository at this point in the history
… streaming with os-lib support.
  • Loading branch information
adamwkaczmarek committed Jan 14, 2025
1 parent aaa1bd5 commit 8441264
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ val zipkinSenderOkHttpVersion = "3.4.3"
val resilience4jVersion = "2.3.0"
val http4s_ce2_version = "0.22.15"
val http4s_ce3_version = "0.23.30"
val osLibVersion = "0.11.3"

val tethysVersion = "0.29.3"

Expand Down Expand Up @@ -976,7 +977,7 @@ lazy val examples = (projectMatrix in file("examples"))
"com.github.plokhotnyuk.jsoniter-scala" %%% "jsoniter-scala-macros" % jsoniterVersion,
"io.github.resilience4j" % "resilience4j-circuitbreaker" % resilience4jVersion,
"io.github.resilience4j" % "resilience4j-ratelimiter" % resilience4jVersion,
"com.lihaoyi" %% "os-lib" % "0.11.3",
"com.lihaoyi" %% "os-lib" % osLibVersion,
pekkoStreams,
logback
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package sttp.client4.examples

import sttp.client4.*
import os.*

private val backend: SyncBackend = DefaultSyncBackend()
private val path: os.Path = os.Path("/tmp/example-file.txt")

@main def cmdOutputStreamingWithOsLib(): Unit = {
os.remove(path)
os.write(path, "CONTENT OF THE SIMPLE FILE USED IN THIS EXAMPLE")
val process = os.proc("cat", path.toString).spawn()
val request = basicRequest
.post(uri"http://httpbin.org/post")
.body(process.stdout.wrapped)
.response(asString)
val response = request.send(backend)
println(response)
}

0 comments on commit 8441264

Please sign in to comment.