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
@arturobernalg
arturobernalg force-pushed the structured-field-values branch from 59a96a3 to 1f35bb5 Compare September 4, 2026 10:53
@arturobernalg
arturobernalg requested a review from ok2c September 4, 2026 10:53
@arturobernalg
arturobernalg force-pushed the structured-field-values branch from 1f35bb5 to e76aafc Compare September 4, 2026 18:53
@arturobernalg
arturobernalg requested a review from ok2c September 4, 2026 18:54
@arturobernalg
arturobernalg force-pushed the structured-field-values branch from e76aafc to e0ae22c Compare September 5, 2026 10:25
@arturobernalg
arturobernalg requested a review from ok2c September 5, 2026 10:33
@arturobernalg
arturobernalg force-pushed the structured-field-values branch from e0ae22c to 803c213 Compare September 8, 2026 05:32
@arturobernalg
arturobernalg requested a review from ok2c September 8, 2026 07:41
@ok2c

ok2c commented Sep 12, 2026

Copy link
Copy Markdown
Member

@arturobernalg Very good. Out of curiosity, how much of this change-set was AI generated? It is perfectly fine. It just looks completely different and that makes me think those classes got generated.

Ideally I would like the #hashCode and #equals methods of the new classes to be consistent with the rest of code base. As well argument validation should ideally be done with Args methods. This is not a must. But consistency would be nice.

@arturobernalg
arturobernalg force-pushed the structured-field-values branch from 1bdbd48 to f4225db Compare September 13, 2026 13:12
@arturobernalg

Copy link
Copy Markdown
Member Author

Ideally I would like the #hashCode and #equals methods of the new classes to be consistent with the rest of code base. As well argument validation should ideally be done with Args methods. This is not a must. But consistency would be nice.

@ok2c done. AI assisted always under my revisions.

@ok2c

ok2c commented Sep 13, 2026

Copy link
Copy Markdown
Member

@ok2c done. AI assisted always under my revisions.

@arturobernalg Very interesting. Did you train it to use our parsing APIs or was that part hand-written?

@ok2c ok2c left a comment

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 #hashCode now look good. Almost there.

*/
public static StructuredFieldBareItem ofDecimal(final BigDecimal value) {
Args.notNull(value, "Decimal value");
if (value.abs().compareTo(DECIMAL_ROUNDING_LIMIT) >= 0) {

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 One can use Args#check here

}
return this.type == StructuredFieldType.BYTE_SEQUENCE
? Arrays.equals((byte[]) this.value, (byte[]) that.value)
: LangUtils.equals(this.value, that.value);

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 Wait. No need to use deprecated methods.

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