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()); parse(State.PATH, path, 0, path.length());
} }
public void setPathQuery(String path) public void setPathQuery(String pathQuery)
{ {
_uri = null; _uri = null;
_path = null; _path = null;
_decodedPath = null; _decodedPath = null;
_param = null; _param = null;
_fragment = null; _fragment = null;
_query = null; /* TODO
if (path != null) * The query is not cleared here, so old values may be retained if there is no query in
parse(State.PATH, path, 0, path.length()); * 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) public void setQuery(String query)

View File

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

View File

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