I have this simple piece of code:
object Main {
def main(args: Array[String]) {
val application = new DefaultApplication(new File(args(0)), this.getClass.getClassLoader, null, Mode.Prod)
Play.start(application)
val test: Future[Int] = WS.url("http://www.bestattungsvergleich.de/go/" + URLEncoder.encode("Döhren", "UTF-8"))
.withFollowRedirects(true)
.withRequestTimeout(5000)
.get()
.map(x => {
println(x.status)
x.status
})
.recover { case e: Exception => {
println(e.getMessage)
1000
}
}
println(Await.result(test, Duration.Inf))
Play.stop()
}
}
Basically I'm using Play! WS utils to get the http response code from a url, the problem is that this url has a temporary redirect (it returns 307) and when redirecting the url appears not to be encoded, this is the message printed from the catch clause:
name contains non-ascii character: lp-loaded-variation-Dᅢᄊhren
I also tried other types of encoding(LATIN1, some ISOs), am I doing something wrong or is it a problem in the redirect checking from Play! web services?
As noted by wingedsubmariner the lp-loaded-variation-Dᅢᄊhren is being returned as part of a Set-Cookie header.
lp-loaded-variation-Dᅢᄊhrenis actually being returned as part of aSet-Cookieheader. I have no idea why Play! decides to choke on this. - wingedsubmariner