Issue #4329 - Fixing RuleContainer to handle path parameters
+ Introducing HttpURI.setParam(String) + Updating DemoBaseTest.testSessionDump() to follow expected behavior Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
4d1031899e
commit
09641c9581
|
@ -573,6 +573,15 @@ public class HttpURI
|
|||
return _param;
|
||||
}
|
||||
|
||||
public void setParam(String param)
|
||||
{
|
||||
_param = param;
|
||||
if (_path != null && !_path.contains(_param))
|
||||
{
|
||||
_path += ";" + _param;
|
||||
}
|
||||
}
|
||||
|
||||
public String getQuery()
|
||||
{
|
||||
return _query;
|
||||
|
|
|
@ -22,8 +22,10 @@ import java.io.IOException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.util.ArrayUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -185,7 +187,18 @@ public class RuleContainer extends Rule implements Dumpable
|
|||
if (rule instanceof Rule.ApplyURI)
|
||||
((Rule.ApplyURI)rule).applyURI(baseRequest, baseRequest.getRequestURI(), encoded);
|
||||
else
|
||||
baseRequest.setURIPathQuery(encoded);
|
||||
{
|
||||
String uriPathQuery = encoded;
|
||||
HttpURI baseUri = baseRequest.getHttpURI();
|
||||
// Copy path params from original URI if present
|
||||
if ((baseUri != null) && StringUtil.isNotBlank(baseUri.getParam()))
|
||||
{
|
||||
HttpURI uri = new HttpURI(uriPathQuery);
|
||||
uri.setParam(baseUri.getParam());
|
||||
uriPathQuery = uri.toString();
|
||||
}
|
||||
baseRequest.setURIPathQuery(uriPathQuery);
|
||||
}
|
||||
}
|
||||
|
||||
if (_rewritePathInfo)
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
|||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
@ -48,7 +47,6 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||
|
||||
public class CookiePatternRuleTest
|
||||
{
|
||||
|
||||
private Server server;
|
||||
private LocalConnector localConnector;
|
||||
|
||||
|
@ -150,7 +148,6 @@ public class CookiePatternRuleTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@Disabled("See #2675 for details") // TODO: needs to be fixed in RuleContainer
|
||||
public void testUrlParameter() throws Exception
|
||||
{
|
||||
CookiePatternRule rule = new CookiePatternRule();
|
||||
|
@ -170,7 +167,6 @@ public class CookiePatternRuleTest
|
|||
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
|
||||
|
||||
String responseContent = response.getContent();
|
||||
System.out.println(responseContent);
|
||||
assertResponseContentLine(responseContent, "baseRequest.requestUri=", "/other;fruit=apple");
|
||||
|
||||
// verify
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.tests.distribution;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.util.FormContentProvider;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.util.Fields;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -35,7 +35,6 @@ import static org.hamcrest.Matchers.containsString;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class DemoBaseTests extends AbstractDistributionTest
|
||||
|
@ -200,17 +199,35 @@ public class DemoBaseTests extends AbstractDistributionTest
|
|||
assertTrue(run.awaitConsoleLogsFor("Started @", 10, TimeUnit.SECONDS));
|
||||
|
||||
startHttpClient();
|
||||
client.setFollowRedirects(true);
|
||||
ContentResponse response = client.GET("http://localhost:" + httpPort + "/test/session/");
|
||||
assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
|
||||
Fields action = new Fields();
|
||||
action.add("Action", "New Session");
|
||||
// Submit "New Session"
|
||||
Fields form = new Fields();
|
||||
form.add("Action", "New Session");
|
||||
response = client.POST("http://localhost:" + httpPort + "/test/session/")
|
||||
.content(new FormContentProvider(action))
|
||||
.content(new FormContentProvider(form))
|
||||
.send();
|
||||
assertEquals(HttpStatus.FOUND_302, response.getStatus());
|
||||
String location = response.getHeaders().get(HttpHeader.LOCATION);
|
||||
assertNotNull(location);
|
||||
assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
String content = response.getContentAsString();
|
||||
assertThat("Content", content, containsString("<b>test:</b> value<br/>"));
|
||||
assertThat("Content", content, containsString("<b>WEBCL:</b> {}<br/>"));
|
||||
|
||||
// Last Location
|
||||
URI location = response.getRequest().getURI();
|
||||
|
||||
// Submit a "Set" for a new entry in the cookie
|
||||
form = new Fields();
|
||||
form.add("Action", "Set");
|
||||
form.add("Name", "Zed");
|
||||
form.add("Value", "[alpha]");
|
||||
response = client.POST(location)
|
||||
.content(new FormContentProvider(form))
|
||||
.send();
|
||||
assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
content = response.getContentAsString();
|
||||
assertThat("Content", content, containsString("<b>Zed:</b> [alpha]<br/>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue