Last active
February 25, 2016 13:12
-
-
Save nisshiee/6414370 to your computer and use it in GitHub Desktop.
Dispatchの文字化け対策
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dispatch._ | |
import com.ning.http.client.filter.{ ResponseFilter, FilterContext } | |
import scala.collection.JavaConverters._ | |
val MyHttp = Http.configure { builder => | |
builder.addResponseFilter(new ResponseFilter { | |
override def filter(ctx: FilterContext[_]) = { | |
ctx.getResponseHeaders.getHeaders.get("Content-Type").asScala.toList match { | |
case "text/html" :: Nil => | |
ctx.getResponseHeaders.getHeaders.put("Content-Type", List("text/html; charset=utf-8").asJava) | |
case _ => () | |
} | |
ctx | |
} | |
}) | |
} | |
MyHttp(url("http://example.com") OK as.String) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment