Skip to content

Instantly share code, notes, and snippets.

@adamw
Created October 19, 2017 11:18
Show Gist options
  • Save adamw/437118c3390b61b849c11c4fdaa17a56 to your computer and use it in GitHub Desktop.
Save adamw/437118c3390b61b849c11c4fdaa17a56 to your computer and use it in GitHub Desktop.
import com.softwaremill.sttp._
val sort: Option[String] = None
val query = "http language:scala"
// the `query` parameter is automatically url-encoded
// `sort` is removed, as the value is not defined
val request = sttp.get(
uri"https://api.github.com/search/repositories?q=$query&sort=$sort")
implicit val backend = HttpURLConnectionBackend()
val response = request.send()
// response.header(...): Option[String]
println(response.header("Content-Length"))
// response.unsafeBody: by default read into a String
println(response.unsafeBody)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment