2011-10-11 38 views
3

302 HTTP重定向的位置,databinder-dispatch 0.8.3我想從一個302 HTTP響應重定向URL,但我得到以下異常:掌握的DataBinder派遣

Caused by: dispatch.StatusCode: Unexpected response code: 302 

這裏是我的已嘗試,與some help

import dispatch._ 
import org.apache.http.{HttpRequest,HttpResponse} 
import org.apache.http.protocol.HttpContext 
import org.apache.http.HttpStatus._ 

val http = new Http { 

    override def make_client = { 
    val client = new ConfiguredHttpClient(new Http.CurrentCredentials(None)) 

    client.setRedirectStrategy(new org.apache.http.impl.client.DefaultRedirectStrategy {  
     override def isRedirected(req: HttpRequest, res: HttpResponse, ctx: HttpContext) = false 
    }) 

    client 
    } 
} 

val req: Request = :/("graph.facebook.com")/"kmels"/"picture" 

val pictureURL: String = http(req.secure >:> { _("Location").head }) //error prone code, but we're just testing. This is the line where the exception is thrown. 

我錯過了什麼?一如既往,在此先感謝。

回答

1

以下工作:

val pictureURL: String = http.x(req.secure >:> { _("Location").head })