-
Notifications
You must be signed in to change notification settings - Fork 566
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
Header APIs consistency #7058
Comments
First proposal: HTTP Header:
HTTP Headers:
Media types:
|
Option if headers.add(Http.HeaderNames.ACCEPT, MediaTypes.TEXT_PLAIN.text()); (1)
Http.HeaderName name = Http.HeaderNames.create("accept", "Accept"); (2)
Http.Header header = Http.Headers.create(name, "value"); (3) (7)
Http.Header header2 = Http.Headers.createCached("Accept", "value"); (6) (7) HTTP Headers HttpHeaders requestHeaders = request.headers(); (4)
WritableHeaders<?> headers = WritableHeaders.create();
headers.update(requestHeaders); (1) // copy all headers from requestHeaders to headers |
@tomas-langer Regarding initial comment. First section:
Don't have a strong opinion on the changes proposed in the other two sections. |
Agreed,
If anybody has a great idea here, please share, I am just not sure. |
The PR is merged, the problems raised in this issue are all addressed (sometimes not in the way proposed here). |
Helidon Version: 4.0.0-ALPHA6
Header name type
We are forcing the use of
HeaderName
instead ofString
to ensure best practice for performance.Thus we are explicitly not overloading the header related methods to support
String
as a type for the header name.The following method exists:
Header value types
Also we have multiple variants of the header methods in order to support different value types, however there are some inconsistencies where some classes only have certain variants.
HeaderValue
The creation of an instance of
HeaderValue
is odd:Both
HeaderName
andHeaderValue
are created viaHeader.create()
Also
HeaderValue
does not model a header value, but an actual pair of header name and header value, which is just a header.Http.Header
class to model that or renamingHeaderValue
to something elseMediaType
MediaType
is now more abstract than it was and has been superseded in practice withHttpMediaType
.On one hand,
MediaTypes
defines constants forMediaType
, butHttpMediaType
defines its own constants.Also, there is a discrepancy in the constants available, E.g.
HttpMediaType.APPLICATION_XML
is not defined.This can be confusing for APIs that require the use of
HttpMediaType
asMediaTypes
.HttpMediaTypes
for the constants ofHttpMediatype
to provide some symmetry and also reduce the gap of the constants available.Both
WritableHeaders.contentType(HttpMediaType mediaType)
andWritableHeaders.contentType(MediaType mediaType)
have the exact same implementation even thoughHttpMediaType
extendsMediatype
.WritableHeaders.contentType(HttpMediaType mediaType)
Both
ServerResponseHeaders.addAcceptPatches(HttpMediaType... acceptableMediaTypes)
andServerResponseHeaders.addAcceptPatches(MediaType... acceptableMediaTypes)
have the exact same implementation event thoughHttpMediaType
extendsMediatype
.ServerResponseHeaders.addAcceptPatches(HttpMediaType... acceptableMediaTypes)
Bulk
WritableHeaders
does not have methods add headers of a givenHeaders
instance.WritableHeaders.add(Headers)
Not sure if
WritableHeaders.set(Headers)
makes sense.The text was updated successfully, but these errors were encountered: