playframework/Play20 — pull request #1060 by nraychaudhuri (2013-06-03 22:05:14+00:00)
Title: AbsoluteURI support in Play Framework 2.1

Seems that play framework doesn't support absolute uri in requests which is required by standard. Issue description is below.

As stated here:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html

> To allow for transition to absoluteURIs in all requests in future versions of HTTP, all HTTP/1.1 servers MUST accept the absoluteURI form in requests, even though HTTP/1.1 clients will only generate them in requests to proxies.

I have client which sends POST-requests to my play-2.1.1 server. He sends it this way:

POST http://172.16.1.227:9000/A8%3aF9%3a4B%3a20%3a89%3a40/1089820966/ HTTP/1.1
Content-Length: 473
Content-Type: application/json
Date: Thu, 25 Apr 2013 15:44:43 GMT
Host: 172.16.1.227:9000
User-Agent: my-client

...some data...

All requests are rejected with "Action not found" error. The very same request which I send using curl is just fine and the only difference between them is curl send it with relative URI:

POST /A8%3aF9%3a4B%3a20%3a89%3a40/1089820966/ HTTP/1.1
Accept: */*
Content-Length: 593
Content-Type: application/json
Host: 172.16.1.227:9000
User-Agent: curl/7.30.0

I created the following simple workaround in Global.scala:

override def onRouteRequest(request: RequestHeader): Option[Handler] = {
if (request.path.startsWith("http://")) {
super.onRouteRequest(request.copy(
path = request.path.replace("http://"+request.host, "")
))
} else super.onRouteRequest(request)
}

And with this workaround all requests from my client are handled correctly.

So can it be handled more transparently for users?