I have the following set-up:
val req = HttpRequest(HttpMethods.GET, Uri("http://www.example.com/blah"))
val response: Future[HttpResponse] = (IO(Http) ? req).mapTo[HttpResponse]
response.map(
resp => {
resp.headers.foreach(h => println(h))
}
)
and the following configuration: spray.can.host-connector.max-redirects = 2
. I know that this URL redirects, but when I examine response headers I don't see the Location header that tells me where it redirects to.
If I change the config to spray.can.host-connector.max-redirects = 1
Location header is there and correct. However, I'd like it not to break if someone in future decides they need more erdirects in the same app. Do I miss anything about spray configuration?
Apparently I misunderstood the Location header. It comes with redirect response, so when I set up max-redirect > 0 and I have a redirect I get the latest response that is already redirected and it does not have a Location header. Spray's HttpResponse is not coupled to immediate request that generated it, so there is no way to figure out what was the URL from which this response came. My solution is to do a manual redirection.