Skip to content

Commit

Permalink
[Fixes #1958] Fix Jetty session IDs when context path contains dots
Browse files Browse the repository at this point in the history
  • Loading branch information
grgrzybek committed Aug 13, 2024
1 parent b70e0e4 commit fd86609
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public void tearDown() throws BundleException {
public void testRoot() throws Exception {
HttpTestClientFactory.createDefaultTestClient()
.withResponseAssertion("Response must contain 'Session:'", resp -> resp.contains("Session:"))
.doGETandExecuteTest("http://127.0.0.1:8181/c/s");
.doGETandExecuteTest("http://127.0.0.1:8181/c.b.d/s");
// test image-serving
HttpTestClientFactory.createDefaultTestClient()
.doGETandExecuteTest("http://127.0.0.1:8181/c/www/logo.png");
.doGETandExecuteTest("http://127.0.0.1:8181/c.b.d/www/logo.png");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public String getExtendedId(HttpSession session) {
if (tilde == -1) {
return eid;
}
int dot = eid.indexOf(".", tilde);
// org.eclipse.jetty.server.session.DefaultSessionIdManager.setWorkerName()
// ensures that there should be no dot in worker name appended to session id
int dot = eid.lastIndexOf(".");
if (dot == -1) {
return eid.substring(0, tilde);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public HttpService addingService(ServiceReference<HttpService> serviceRef) {
// whiteboard-register this context, so we can set its context path
Dictionary<String, Object> props = new Hashtable<>();
props.put(PaxWebConstants.SERVICE_PROPERTY_HTTP_CONTEXT_ID, "custom");
props.put(PaxWebConstants.SERVICE_PROPERTY_HTTP_CONTEXT_PATH, "/c");
props.put(PaxWebConstants.SERVICE_PROPERTY_HTTP_CONTEXT_PATH, "/c.b.d");
reg = context.registerService(HttpContext.class, httpContext, props);

return httpService;
Expand Down

0 comments on commit fd86609

Please sign in to comment.