title: How do I use Scala dispatch to get the URL returned in a 301 redirect?
body: <p>I am using Scala <a href="http://dispatch.databinder.net/Dispatch.html" rel="noreferrer">dispatch</a> HTTP library, version 0.10.1. I make a request to a URL that returns an HTTP 301, permanent redirect. For example, <a href="http://wikipedia.com" rel="noreferrer">http://wikipedia.com</a> returns a 301 that redirects to <a href="http://www.wikipedia.org/" rel="noreferrer">http://www.wikipedia.org/</a>. How do I do I use dispatch to get the redirected URL?</p>
  
  <p>Following the tutorial, here's what I've done.</p>
  
  <pre><code>import dispatch._, Defaults._
  val svc = url("http://wikipedia.com")
  val r = Http(svc OK as.String)
  r()
  </code></pre>
  
  <p>This throws a "Unexpected response status: 301" exception. Presumably I need to either query the <code>r</code> value for the redirected URL, or maybe specify some argument other than <code>OK</code> in its definition, but I can't figure out what to do from the documentation.</p>