Dispatch → Common Tasks
Assuming:
import dispatch._
val http = new Http
val req = :/("example.com") / "path"
Add a header:
val rhead = req <:< Map("Cache-control" -> "no-cache")
Parse to Scala XML Elem:
http(req / "somefile.xml" <> { _ \\ "book" }) // find all <book> tags
Supply basic or digest authorization credentials:
val rauth = req as ("user", "secret")
Append a query string:
val rquery = req <<? Map("key" -> "value")
Post as a form:
val rform = req << Map("key" -> "value")
Handle response body as a Source:
http(req >~ { _.getLines.foreach(println) })
Request with https:
val rsec = req.secure