How do I use Scala dispatch to get the URL returned in a 301 redirect?

↘锁芯ラ 提交于 2019-12-03 12:43:25

Configure the underlying asyncClient to follow redirects:

val r = Http.configure(_ setFollowRedirects true)(svc OK as.String)

To get the redirected URL:

val svc = url("http://wikipedia.com/")
val r = Http(svc > (x => x))
val res = r()

println(res.getHeader("Location"))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!