Skip to content

Commit

Permalink
Re re Fix rewrite tests for #5954
Browse files Browse the repository at this point in the history
Re re Fix rewrite tests for #5954. Restore setPathQuery behaviour to preserve queries if none are set.
  • Loading branch information
gregw committed Feb 17, 2021
1 parent 3d19679 commit dd5a565
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 8 additions & 4 deletions jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java
Expand Up @@ -821,16 +821,20 @@ public void setPath(String path)
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)
Expand Down
Expand Up @@ -90,15 +90,13 @@ public String apply(String target, HttpServletRequest request, HttpServletRespon
@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
Expand Down

0 comments on commit dd5a565

Please sign in to comment.