Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-9.4.x-new-header-rules

This commit is contained in:
Joakim Erdfelt 2021-02-17 06:40:03 -06:00
commit 30c1b467c8
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
3 changed files with 13 additions and 6 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

@ -256,6 +256,9 @@ public class HttpURITest
assertThat(uri.getPathQuery(), is("/other;xxx/path;ppp?query"));
uri.setPathQuery(null);
assertEquals("http://host:8080?query", uri.toString()); // Yes silly result!
uri.setQuery(null);
assertEquals("http://host:8080", uri.toString());
uri.setPathQuery("/other;xxx/path;ppp?query");

View File

@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.is;
public class RewritePatternRuleTest extends AbstractRuleTestCase
{
// TODO: Parameterize
private String[][] _tests =
private final String[][] _tests =
{
{"/foo/bar", "/", "/replace"},
{"/foo/bar", "/*", "/replace/foo/bar"},
@ -98,8 +98,8 @@ public class RewritePatternRuleTest extends AbstractRuleTestCase
assertThat("result matches expected", result, is(replacement));
rewritePatternRule.applyURI(_request, null, result);
assertThat("queryString matches expected", _request.getQueryString(), is(queryString));
assertThat("request URI matches expected", _request.getRequestURI(), is(replacement));
assertThat("queryString matches expected", _request.getQueryString(), is(queryString));
}
@Test