This reports (and fixes) two bugs and provided one requested feature.
The first bug is basically the same as 3042444, but fixed in a slightly different way.
The second is the omission of the context path when rewriting cookies.
The feature is that requested in 3605676, which finds URLs in AJAX calls where "url: 'someuri'" is used.
These are all implemented in the two modified files attached.
Modified UrlRewritingOutputStream to handle url: elements
Modified to handle character encoding and context root in cookies