joerghoh commented on code in PR #88:
URL:
https://github.com/apache/sling-org-apache-sling-api/pull/88#discussion_r4538309707
##########
src/main/java/org/apache/sling/api/request/header/JakartaMediaRangeList.java:
##########
@@ -281,6 +309,45 @@ public Map<String, String> getParameters() {
return parameters != null ? parameters : new HashMap<String,
String>(0);
}
+ private boolean matches(MediaRange mediaType) {
+ if ((!WILDCARD.equals(supertype) &&
!supertype.equalsIgnoreCase(mediaType.supertype))
+ || (!WILDCARD.equals(subtype) &&
!subtype.equalsIgnoreCase(mediaType.subtype))) {
+ return false;
+ }
+ if (parameters != null) {
+ for (Map.Entry<String, String> parameter :
parameters.entrySet()) {
+ if ("q".equals(parameter.getKey())) {
+ break;
+ }
+ if
(!parameter.getValue().equals(mediaType.getParameter(parameter.getKey()))) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private int compareSpecificity(MediaRange other) {
+ int typeSpecificity = matchesAll() ? 0 : WILDCARD.equals(subtype)
? 1 : 2;
+ int otherTypeSpecificity = other.matchesAll() ? 0 :
WILDCARD.equals(other.subtype) ? 1 : 2;
+ return typeSpecificity != otherTypeSpecificity
+ ? Integer.compare(typeSpecificity, otherTypeSpecificity)
+ : Integer.compare(mediaParameterCount(),
other.mediaParameterCount());
+ }
Review Comment:
I don't find that a wildcard supertype is possible (meaning something like
``*/json``), see https://httpwg.org/specs/rfc9110.html#field.accept
It allows wildcards only on these 2 cases:
* ``*/*``
* ``mediatype/*``
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]