How to read long from an Akka-HTTP response stream of an unknown length?
example :
val futureResponse = Http(system).singleRequest(
HttpRequest(
HttpMethods.POST,
"url",
entity = HttpEntity(ContentTypes.`application/json`, "somequery".getBytes())
).withHeaders(RawHeader("X-Access-Token", "access token"))
)
futureResponse.map {
res =>
res.entity.dataBytes
.map(convertToLong) // convert to long/int
.grouped(2) // group two elments together
.map(getRelation)// do some transform
.runWith(someSink) // write to sink
}
how can we transform ByteString
to the Long
the above stream?