Skip to content

Commit

Permalink
Fix #11290 empty field (#11291)
Browse files Browse the repository at this point in the history
Fixed cacheable empty field for #11290
  • Loading branch information
gregw authored Jan 18, 2024
1 parent 8cc7abe commit a2d86c7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,7 @@ else if (!_cache.put(field))

public boolean cacheable(HttpHeader header, String valueString)
{
return isEnabled() && header != null && valueString.length() <= _size;
return isEnabled() && header != null && valueString != null && valueString.length() <= _size;
}

private void prepare()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,23 @@ public void testNoValue(String eoln)
ByteBuffer buffer = BufferUtil.toBuffer(
"GET / HTTP/1.0" + eoln +
"Host: localhost" + eoln +
"Name0: " + eoln +
"Name0: " + eoln +
"Name1:" + eoln +
"Authorization: " + eoln +
"Authorization:" + eoln +
eoln);

HttpParser.RequestHandler handler = new Handler();
HttpParser.RequestHandler handler = new Handler()
{
@Override
public void badMessage(HttpException failure)
{
((Throwable)failure).printStackTrace();
super.badMessage(failure);
}
};
HttpParser parser = new HttpParser(handler);
parser.setHeaderCacheSize(1024);
parseAll(parser, buffer);

assertTrue(_headerCompleted);
Expand All @@ -576,7 +587,11 @@ public void testNoValue(String eoln)
assertEquals("", _val[1]);
assertEquals("Name1", _hdr[2]);
assertEquals("", _val[2]);
assertEquals(2, _headers);
assertEquals("Authorization", _hdr[3]);
assertEquals("", _val[3]);
assertEquals("Authorization", _hdr[4]);
assertEquals("", _val[4]);
assertEquals(4, _headers);
}

@ParameterizedTest
Expand Down

0 comments on commit a2d86c7

Please sign in to comment.