You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** Splits the path segments and adds each of them to the path url-encoded. * A segment is delimited by / * @parammorePath the path to add * @return a new uri with the segments added to the path*/defaddPath(morePath: String):Uri=
copy(path = morePath.split("/").foldLeft(path)((p, segment) => p.addSegment(segment)))
scala-cli reproduction:
// using scala 2.13.7// using lib org.http4s::http4s-ember-client:0.23.7// using lib com.disneystreaming.smithy4s::smithy4s-http4s:0.11.3// using lib com.disneystreaming.smithy4s::smithy4s-tests:0.11.3importcats.effect.IOimportcats.effect.IOAppimportcats.effect.kernel.Resourceimportorg.http4s.Responseimportorg.http4s.client.Clientimportorg.http4s.implicits._importsmithy4s.example.PizzaAdminServiceimportsmithy4s.http4s.SimpleRestJsonBuilderobjectdemoextendsIOApp.Simple {
defrun:IO[Unit] = {
valclient=Client[IO] { req =>Resource.eval(IO.println("Actual: "+ req.uri.renderString) *>IO(Response[IO]()))
}
SimpleRestJsonBuilder(PizzaAdminService)
.clientResource(client, uri"http://localhost:8080")
.use { client =>valexpected=uri"http://localhost:8080"/"restaurant"/"hello%world"/"menu"IO.println("Expected: "+ expected.renderString) *>
client.getMenu("hello%world")
}
}.void
}
Additionally (this is probably a separate issue, I'm not sure), characters like colons are encoded while they shouldn't be (e.g. https://en.wikipedia.org/wiki/Template:Welcome is fine): the same code with "hello:world" as the parameter outputs:
I'm starting to think we shouldn't be doing urlencoding at all, and path rendering should be left to the interpreters. In the case of the http4s client, we'd pass a collection of segments to baseUri.path.addSegments. I'm not 100% sure this will work with greedy labels yet.
The text was updated successfully, but these errors were encountered:
I think the double encoding part is a regression introduced in #41, which can be blamed on me 😅 the path: String method was being built incorrectly, though. Maybe we don't need it? Maybe we can have a List[String or some newtype for Segment] instead (and as I mentioned in the original post, encode these in the interpreters)?
Path segments like
foo%bar
get encoded twice: once inHttpEndpoint#path
and again in the endpoint'sinputToRequest
:For context, here's
addPath
from http4s:scala-cli reproduction:
Outputs:
Additionally (this is probably a separate issue, I'm not sure), characters like colons are encoded while they shouldn't be (e.g. https://en.wikipedia.org/wiki/Template:Welcome is fine): the same code with
"hello:world"
as the parameter outputs:I'm starting to think we shouldn't be doing urlencoding at all, and path rendering should be left to the interpreters. In the case of the http4s client, we'd pass a collection of segments to
baseUri.path.addSegments
. I'm not 100% sure this will work with greedy labels yet.The text was updated successfully, but these errors were encountered: