While we are waiting for the next release of rack that will come with that fix, I extract a code from a pull request in rack repository and created a monkey patch to fix this problem.
This problem often happens when you are using google analytics or another service