Re re Fix rewrite tests for #5954

Re re Fix rewrite tests for #5954. Restore setPathQuery behaviour to preserve queries if none are set.
This commit is contained in:
gregw 2021-02-17 12:12:56 +01:00
parent 3d19679d10
commit dd5a565c08
2 changed files with 9 additions and 7 deletions

View File

@ -821,16 +821,20 @@ public class HttpURI
parse(State.PATH, path, 0, path.length());
}
public void setPathQuery(String path)
public void setPathQuery(String pathQuery)
{
_uri = null;
_path = null;
_decodedPath = null;
_param = null;
_fragment = null;
_query = null;
if (path != null)
parse(State.PATH, path, 0, path.length());
/* TODO
* The query is not cleared here, so old values may be retained if there is no query in
* the pathQuery. This is probably a bug, but other code now expects this behaviour, so
* we will keep it in 9 and fix in 10.
*/
if (pathQuery != null)
parse(State.PATH, pathQuery, 0, pathQuery.length());
}
public void setQuery(String query)

View File

@ -90,15 +90,13 @@ public class RewritePatternRule extends PatternRule implements Rule.ApplyURI
@Override
public void applyURI(Request request, String oldURI, String newURI) throws IOException
{
String queryString = request.getQueryString();
if (_query == null)
{
request.setURIPathQuery(newURI);
if (queryString != null)
request.setQueryString(queryString);
}
else
{
String queryString = request.getQueryString();
if (queryString != null)
queryString = queryString + "&" + _query;
else