Skip to content

Commit

Permalink
Document that uri throws.
Browse files Browse the repository at this point in the history
  • Loading branch information
htmldoug committed Jun 10, 2019
1 parent 65f6596 commit cfaa783
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package play.api.libs.ws.ahc

import java.io.UnsupportedEncodingException
import java.net.URI
import java.net.{ URI, URISyntaxException }
import java.nio.charset.{ Charset, StandardCharsets }

import akka.stream.Materializer
Expand Down Expand Up @@ -51,6 +51,7 @@ case class StandaloneAhcWSRequest(

override def contentType: Option[String] = this.headers.get(HttpHeaders.Names.CONTENT_TYPE).map(_.head)

@throws[URISyntaxException]("If the url is invalid.")
override lazy val uri: URI = {
val enc = (p: String) => java.net.URLEncoder.encode(p, "utf-8")
new java.net.URI(if (queryString.isEmpty) url else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package play.api.libs.ws.ahc

import java.net.URISyntaxException

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.util.ByteString
Expand All @@ -16,6 +18,7 @@ import play.api.libs.ws._
import play.shaded.ahc.io.netty.handler.codec.http.HttpHeaderNames
import play.shaded.ahc.org.asynchttpclient.Realm.AuthScheme
import play.shaded.ahc.org.asynchttpclient.{ Param, SignatureCalculator, Request => AHCRequest }

import scala.collection.JavaConverters._
import scala.concurrent.duration._

Expand Down Expand Up @@ -106,6 +109,13 @@ class AhcWSRequestSpec extends Specification with Mockito with AfterAll with Def

}

"uri should not throw" in {
withClient { client =>
val req = client.url("https://github.com/playframework/play-ws/issues/267/?pipe=|")
req.uri must not(throwAn[URISyntaxException])
}
}.pendingUntilFixed("issue #267")

}

"For Cookies" in {
Expand Down

0 comments on commit cfaa783

Please sign in to comment.