whitespace in param #75

Closed
sshastry opened this Issue Nov 20, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@sshastry

hey! having some trouble with the router in http4s v0.4.0.

object X extends ParamMatcher("x")
object Y extends ParamMatcher("y")

class App(hostname: String = "localhost", port: Int = 9999)(implicit ec: ExecutionContext = ExecutionContext.global) extends Logging {
  def run = BlazeBuilder.bindHttp(port, hostname).mountService(service, "/").run.awaitShutdown()
  def logreq(r: Request): Unit = log.info(s"${r.remoteAddr.getOrElse("null")} -> ${r.method}: ${r.uri.path} ${r.uri.query}")

  lazy val service = HttpService {
    case req @ GET -> Root / "blah" :? X(x0) +& Y(y0) =>
      logreq(req)
      log.info(s"x0=${x0}, y0=${y0}")
      Ok("x = " + x0 + "\n" + "y = " + y0)
    case req =>
      logreq(req)
      NotFound("404: not found")
  }
}

(here's the full file: https://gist.github.com/sshastry/874fa6ce2431e3725e9f)

http://localhost:8080/blah?x=abc&y=ijk works and binds "abc" to x0 and "ijk" to y0.

but http://localhost:8080/blah?x=a+bc&y=ijk falls through to the NotFound route, contrary to my expectation that it would bind "a bc" to x0. likewise for http://localhost:8080/blah?x=a%20bc&y=ijk.

this is what the log shows:

14:47:43.370 [pool-6-thread-1] INFO  org.app.App - 127.0.0.1 -> GET: /blah Some(x=a bc&y=ijk)

something simple I'm overlooking? thanks!

bryce-anderson added a commit that referenced this issue Nov 20, 2014

UriParser now _doesn't_ decode the query string
fixes #75
The QueryParser expects a url encoded string, but the UriParser
predecodes it. This fixes the problem at the cost of needing to
manually decode the query String if all you really want is the String.

bryce-anderson added a commit that referenced this issue Nov 21, 2014

Uri Fragment is no longer decoded by the RequestUriParser
Also added a few more tests to the UriSpec
issue #75.

@rossabaker rossabaker added the bug label Nov 21, 2014

@rossabaker rossabaker added this to the 0.4.1 milestone Nov 21, 2014

@bryce-anderson

This comment has been minimized.

Show comment
Hide comment
@bryce-anderson

bryce-anderson Nov 21, 2014

Member

@sshastry this should be fixed, but can you confirm? if it works for you we will do a 0.4.1 release with this bug fix to get a working artifact out there.

Member

bryce-anderson commented Nov 21, 2014

@sshastry this should be fixed, but can you confirm? if it works for you we will do a 0.4.1 release with this bug fix to get a working artifact out there.

@sshastry

This comment has been minimized.

Show comment
Hide comment
@sshastry

sshastry Nov 21, 2014

confirmed working.

confirmed working.

@bryce-anderson

This comment has been minimized.

Show comment
Hide comment
@bryce-anderson

bryce-anderson Nov 21, 2014

Member

Perfect, thank you.

Member

bryce-anderson commented Nov 21, 2014

Perfect, thank you.

bryce-anderson added a commit that referenced this issue Nov 21, 2014

Uri Fragment is no longer decoded by the RequestUriParser
Also added a few more tests to the UriSpec
issue #75.

Conflicts:
	core/src/main/scala/org/http4s/Uri.scala
	core/src/main/scala/org/http4s/parser/Rfc3986Parser.scala
	core/src/test/scala/org/http4s/UriSpec.scala

rossabaker pushed a commit that referenced this issue Mar 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment