Skip to content

RFC 9651: Structured Field Values for HTTP - #693

Open
arturobernalg wants to merge 1 commit into
apache:masterfrom
arturobernalg:structured-field-values
Open

RFC 9651: Structured Field Values for HTTP#693
arturobernalg wants to merge 1 commit into
apache:masterfrom
arturobernalg:structured-field-values

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Adds Structured Field Values (RFC 9651) support under org.apache.hc.core5.http.structured: a strict single-pass parser, a canonical serializer, and an immutable value model covering Items, Lists, Dictionaries, parameters and inner lists, and all eight bare-item types (Integer, Decimal, String, Token, Byte Sequence, Boolean, Date, Display String). StructuredFieldHeaders integrates it with message headers. Values are validated and normalized on construction, so serialization is total and round-trips are canonical.

@arturobernalg
arturobernalg requested a review from ok2c September 3, 2026 16:25
if (cursor.getUpperBound() > input.length()) {
throw new IllegalArgumentException("Parser cursor exceeds Structured Field input length");
}
for (int i = cursor.getPos(); i < cursor.getUpperBound(); i++) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@arturobernalg We do permit non-ASCII characters in HTTP message header fields if the underlying connection has been configured with a custom CharCodingConfig. Can we be a bit more lenient here and also avoid this full header scan?

private String parseDisplayString() throws ParseException {
require('%');
require(Tokenizer.DQUOTE);
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@arturobernalg Would you consider using ByteArrayBuffer here instead? It would be more efficient by not being synchronized and by avoiding an extra byte array copy,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants