Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #11290 empty field #11291

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this override still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it as before the fix it was very unclear how it was failing.

{
((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