Skip to content

Commit

Permalink
Fix #5327 NPE in PushBuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Wilkins <gregw@webtide.com>
  • Loading branch information
gregw committed Sep 27, 2020
1 parent d77911e commit bd4b210
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public PushBuilder newPushBuilder()

HttpField authField = getHttpFields().getField(HttpHeader.AUTHORIZATION);
//TODO check what to do for digest etc etc
if (getUserPrincipal() != null && authField.getValue().startsWith("Basic"))
if (authField != null && getUserPrincipal() != null && authField.getValue().startsWith("Basic"))
fields.add(authField);

String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,25 @@ public void testPushBuilder() throws Exception
assertThat(builder.getHeader("Cookie"), not(containsString("bad")));
}

@Test
public void testPushBuilderWithIdNoAuth() throws Exception
{
String uri = "/foo/something";
Request request = new TestRequest(null, null)
{
@Override
public Principal getUserPrincipal()
{
return () -> "test";
}
};
HttpFields.Mutable fields = HttpFields.build();
request.setMetaData(new MetaData.Request("GET", HttpURI.from(uri), HttpVersion.HTTP_1_0, fields));
assertTrue(request.isPushSupported());
PushBuilder builder = request.newPushBuilder();
assertNotNull(builder);
}

@Test
public void testServletPathMapping() throws Exception
{
Expand Down

0 comments on commit bd4b210

Please sign in to comment.