Last active
September 16, 2020 16:59
-
-
Save adamw/91c670fde8e898646a25d1011183b808 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client3.examples | |
import io.circe | |
import io.circe.generic.auto._ | |
import sttp.client3._ | |
import sttp.client3.circe._ | |
object GetRawRequestBodySynchronous extends App { | |
case class HttpBinResponse(origin: String, headers: Map[String, String]) | |
val request = basicRequest | |
.get(uri"https://httpbin.org/get") | |
.response(asBoth(asJson[HttpBinResponse], asStringAlways)) | |
val backend: SttpBackend[Identity, Any] = HttpURLConnectionBackend() | |
try { | |
val response: Response[(Either[ResponseException[String, circe.Error], HttpBinResponse], String)] = | |
request.send(backend) | |
val (parsed, raw) = response.body | |
println("Got response - parsed: " + parsed) | |
println("Got response - raw: " + raw) | |
} finally backend.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment