Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: support for bad clients that send literal spaces in the request URI? #17995
I've written an HTTP server using Go for XBMC/Kodi clients. Kodi is a widely used open-source media player. In fact Kodi uses webdav, so I've implemented this with x/net/webdav, which is built on the standard net/http.
The problem is that Kodi (and its predecessor, XBMC) will send plain spaces in URIs. They're not encoded as %20. This is certainly a bug- but Apache and Lighttpd accept that, as they parse the request line by finding the first space from the left, everything before that is the HTTP Method, and the first space from the right, everything after that is the HTTP Version, and anything in between is the request URI.
net/http/request.go however just looks for the first and second space:
So it doesn't work with XBMC/Kodi clients, and possibly others.
This can be fixed easily with the following patch:
Now, ofcourse, it is debatable whether net/http should support such buggy clients. So if you think that it should not, just close this bug report.
Which HTTP client library do XBMC/Kodi use? Is there an upstream bug already filed for them to fix their HTTP client?
If so, and this problem is temporary, I might be amenable to accepting this garbage since it fixes a real client, but I won't do it unless upstream is also fixed.
I've researched this some more, and I found that NGINX had a similar issue with XBMC/Kodi. It was because the nginx webdav module didn't properly escape 'href' in the XML PROPFIND response. XBMC/Kodi then uses that href url unmodified and unescaped.
Digging a bit further I found that golangs x/net/webdav had the exact same problem, but that it since has been fixed by:
x/net/webdav: percent-encode D:href in the XML.
Indeed, with a newer x/net/webdav, the bug doesn't happen anymore.
I think you can close this bug now. Thanks.