Permalink
Browse files

URLEncoding in querystring Writeable

  • Loading branch information...
erwan committed Apr 2, 2012
1 parent 745cb77 commit bf8b9ec007bd1f3da3486dfade96e7f2a46a7aca
@@ -61,7 +61,10 @@ trait DefaultWriteables extends LowPriorityWriteables {
* `Writeable` for `urlEncodedForm` values
*/
implicit def writeableOf_urlEncodedForm(implicit codec: Codec): Writeable[Map[String, Seq[String]]] = {
- Writeable[Map[String, Seq[String]]](formData => codec.encode(formData.map(item => item._2.map(c => item._1 + "=" + c)).flatten.mkString("&")))
+ import java.net.URLEncoder
+ Writeable[Map[String, Seq[String]]](formData =>
+ codec.encode(formData.map(item => item._2.map(c => item._1 + "=" + URLEncoder.encode(c, "UTF-8"))).flatten.mkString("&"))
+ )

This comment has been minimized.

Show comment Hide comment
@julienrf

julienrf Apr 3, 2012

Contributor

I think we should provide a more specific type than Map[String, Seq[String]]. What about QueryString? BTW we could add some useful methods such as getSimple(k: String): Option[String] which would be a shorthand for get(k).map(_.headOption)

@julienrf

julienrf Apr 3, 2012

Contributor

I think we should provide a more specific type than Map[String, Seq[String]]. What about QueryString? BTW we could add some useful methods such as getSimple(k: String): Option[String] which would be a shorthand for get(k).map(_.headOption)

}
/**
@@ -79,7 +79,6 @@ object OpenID {
val server: Promise[String] = endPoint.map(PurePromise(_)).getOrElse(discoverServer(id).map(_.url))
server.flatMap(url => {
val fields = (queryString - "openid.mode" + ("openid.mode" -> Seq("check_authentication")))
- .mapValues(_.map(URLEncoder.encode(_, "UTF-8")))
WS.url(url).post(fields).map(response => {
if (response.status == 200 && response.body.contains("is_valid:true")) {
UserInfo(queryString)

0 comments on commit bf8b9ec

Please sign in to comment.