Questions tagged [sttp]

The Scala HTTP client

31 questions
4
votes
1 answer

How to read response as Observable[String] with sttp

I'm using sttp client. I want to intepret response as strings divided by lines, eg Observable[String] Here sttp streaming api: import java.nio.ByteBuffer import com.softwaremill.sttp._ import…
zella
  • 4,645
  • 6
  • 35
  • 60
3
votes
1 answer

How can I send HTTP Requests asynchronously while handling rate-limits?

Disclaimer: I am new to sttp and Monix, and that is my attempt to learn more about these libraries. My goal is to fetch data (client-side) from a given API via HTTP GET requests -> parse JSON responses -> write this information to a database. My…
alt-f4
  • 2,112
  • 17
  • 49
3
votes
1 answer

Write data to file in chunks using akka streams

I use sttp lib with akka backend to load a file from server. Either of the following approaches results in significant memory footprint to load 1Gb file: import com.softwaremill.sttp._ val file: File = new…
morsik
  • 1,250
  • 14
  • 17
3
votes
1 answer

How can I use the Scala sttp FetchBackend for handling JavaScript in html?

I need to execute JavaScript in HTML responses. I am using sttp version 1.5.12. According to the documentation I just need to include implicit val sttpBackend = FetchBackend() but it's not working. See documentation at :…
2
votes
2 answers

How can I deserialize an non-fixed array of jsons using Circe's manual decoder?

I have a JSON that looks like: { "data": [ { "id": "1", "email": "hello@world.com", "name": "Mr foo", "roles": [ "Chief Bar Officer" ], "avatar_url": null, "phone_number": null }, { …
alt-f4
  • 2,112
  • 17
  • 49
2
votes
1 answer

How can I run parSequenceUnordered of Monix, and handle the results of each task?

I am currently working on implementing client-side http requests to an API, and decided to explore sttp & monix for this task. As I am new to Monix, I am still not sure how to run tasks and retrieve their results. My objective is to have a sequence…
alt-f4
  • 2,112
  • 17
  • 49
2
votes
1 answer

Is synchronous HTTP request wrapped in a Future considered CPU or IO bound?

Consider the following two snippets where first wraps scalaj-http requests with Future, whilst second uses async-http-client Sync client wrapped with Future using global EC object SyncClientWithFuture { def main(args: Array[String]): Unit = { …
Mario Galic
  • 47,285
  • 6
  • 56
  • 98
1
vote
2 answers

How to use scala sttp client to download file

I have task to check AWS pricing, it's a public json file. there is no auth needed. I use Tapir Sttp library val request: Request[Either[String, String], Any] = basicRequest .header(HeaderNames.Accept,…
Weever
  • 13
  • 2
1
vote
1 answer

sttp/tapir - testing endpoint with JSON body

I have some tapir endpoints defined as part of a zio-http server. Everything works for real, including those POST endpoints with JSON bodies. However, I've been unable to get a unit test using SttpBackendStub & TapirStubInterpreter to work for…
1
vote
0 answers

Scala, ZIO, Sttp, Circe - how to map error response to custom trait in sttp client using circe?

I have a simple sttp client implementation: basicRequest.auth .get(...) .response(asJsonEither[GeneralTrait, MyResponse]) .send(backend) .map(_.body.left.map { case HttpError(body, statusCode) =>…
Developus
  • 1,400
  • 2
  • 14
  • 50
1
vote
1 answer

Scala function that takes dynamic class as parameter

Alrighty, a realtime example of what I'm trying to do. I am using Scala Sttp as my Http Client. I have bunch of requests, so I wanted to make it more abstract. I wanted to generalise all get requests under abstract function that would look something…
vukojevicf
  • 609
  • 1
  • 4
  • 22
1
vote
1 answer

How to create ZStream of String from ZStream of Byte

I need to read file from http. I'm using sttp with ZioBackend like this: val sttpBackend: SttpBackend[Task, ZioStreams] = ??? val request = basicRequest .post(uri"...") .response(asStreamUnsafe(ZioStreams)) …
Izbassar Tolegen
  • 1,990
  • 2
  • 20
  • 37
1
vote
1 answer

How to implement STTP SSL requests with HttpClientZioBackend? (SCALA/ZIO)

I am using SttpAPI to send http requests, for one of my requests I need to use mutual SSL and i'm failing to find instructions how to implement it. My backend is HttpClientZioBackend and there is no documentation for customizing the SSL Context for…
ori888
  • 740
  • 1
  • 8
  • 17
1
vote
1 answer

Sttp Client 3 with ZLayer type mismatch

I use ZLayer and Sttp Client(async to create simple http requester application but I found type mismatch error that I couldn't solve it. Can anyone tell me why I'm getting the type mismatch error? I use these versions of scala & libraries. java ->…
tofu511
  • 11
  • 1
1
vote
1 answer

How can I close the STTP backend after completing my requests?

I am currently learning and playing around with STTP using the Monix backend. I am mainly stuck with closing the backend after all my requests (each request is a task) have been processed. I have created sample/mock code to resemble my issue (to my…
alt-f4
  • 2,112
  • 17
  • 49
1
2