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

Process headers to ensure compatibility between legacy and netty validation #30632

Open
wants to merge 4 commits into
base: netty-transport-http
Choose a base branch
from

Conversation

mrsaldana
Copy link
Member

@mrsaldana mrsaldana commented Jan 23, 2025

This PR introduces a HeaderValidator utility class for validating HTTP header names and values. Validation is made to comply with RFC 7230, Section 3.2. This RFC refers to "HTTP/1.1 Message Syntax and Routing" and Section 3.2 covers "Header Fields". In addition to enforcing strict checks to ensure the header is compliant, the utility normalizes the tokens by stripping whitespace padding and lower-casing header field names.

Testing

The accompanying unit tests confirm expected behaviors on:

  • Header name validation
  • Header value validation
  • Length validation
  • Null input handling
  • Header field normalization

Usage

String headerName = HeaderValidator.process("Content-Type", FieldType.NAME, config);
String headerValue = HeaderValidator.process(" application/json ", FieldType.VALUE, config);
// Normalized headerName: "content-type"
// Normalized headerValue: "application/json"

@mrsaldana mrsaldana self-assigned this Jan 23, 2025
@mrsaldana mrsaldana force-pushed the netty-transport-http-responseMessageImprovements branch from 324000c to 7b70122 Compare January 24, 2025 14:33
@mrsaldana
Copy link
Member Author

Enhancements for translating warning messages on validator will be resolved by #30653

pnicolucci
pnicolucci previously approved these changes Jan 28, 2025
isaacrivriv
isaacrivriv previously approved these changes Jan 28, 2025
Copy link
Member

@isaacrivriv isaacrivriv left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks!!

@mrsaldana mrsaldana dismissed stale reviews from isaacrivriv and pnicolucci via da35211 January 30, 2025 14:55
@mrsaldana mrsaldana force-pushed the netty-transport-http-responseMessageImprovements branch from da35211 to 1f5747e Compare January 30, 2025 15:48
@mrsaldana mrsaldana force-pushed the netty-transport-http-responseMessageImprovements branch from 1f5747e to ba62532 Compare January 31, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needed for beta
Development

Successfully merging this pull request may close these issues.

3 participants