Merged
Conversation
scottf
commented
Oct 8, 2025
| lengthMap.put(key, oldLen + checked.len); | ||
| serialized = null; // since the data changed, clear this so it's rebuilt | ||
| } | ||
| CheckState checked = check(key, values); |
Contributor
Author
There was a problem hiding this comment.
the check method is a refactor of all the checks and validations, plus bringing everything inline.
scottf
commented
Oct 8, 2025
| int len = key.length(); | ||
| for (int idx = 0; idx < len; idx++) { | ||
| // Check the key to ensure it matches the specification for keys. | ||
| int keyLen = key.length(); |
Contributor
Author
There was a problem hiding this comment.
instead of repeatedly calling .length
scottf
commented
Oct 8, 2025
| static void checkKey(String key) { | ||
| // key cannot be null or empty and contain only printable characters except colon | ||
| static CheckState check(String key, Collection<String> values) { | ||
| if (key == null || key.isEmpty()) { |
Contributor
Author
There was a problem hiding this comment.
the refactor does the key validation. Before, _put did this and then the old checker also did it, meaning it was checked twice. _add did it correctly in the checker.
scottf
commented
Oct 8, 2025
| } | ||
| } | ||
| list.add(val); | ||
| len += keyLen + valLen + 3; // 3 is for the colon, cr and lf |
Contributor
Author
There was a problem hiding this comment.
length is zero if there were only null values
scottf
commented
Oct 8, 2025
| if (opts == null) { | ||
| return headers; | ||
| } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
if there aren't any opts, just short circuit. This is probably the most common way publish is called.
scottf
commented
Oct 8, 2025
| } | ||
| return h.add(key, value); | ||
| // this is always an internal header with one value per key | ||
| return h.put(key, Collections.singletonList(value)); |
Contributor
Author
There was a problem hiding this comment.
switch to put because there will only every be one of each key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.