Parsers an HTTP header as a Priority header as defined by RFC 9218. @param input The header to parse @return The resulting priority @throws IOException If an I/O error occurs while reading the input
(Reader input)
| 97 | * @throws IOException If an I/O error occurs while reading the input |
| 98 | */ |
| 99 | public static Priority parsePriority(Reader input) throws IOException { |
| 100 | Priority result = new Priority(); |
| 101 | |
| 102 | SfDictionary dictionary = StructuredField.parseSfDictionary(input); |
| 103 | |
| 104 | SfListMember urgencyListMember = dictionary.getDictionaryMember("u"); |
| 105 | // If not an integer, ignore it |
| 106 | if (urgencyListMember instanceof SfInteger) { |
| 107 | long urgency = ((SfInteger) urgencyListMember).getValue().longValue(); |
| 108 | // If out of range, ignore it |
| 109 | if (urgency > -1 && urgency < 8) { |
| 110 | result.setUrgency((int) urgency); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | SfListMember incrementalListMember = dictionary.getDictionaryMember("i"); |
| 115 | // If not a boolean, ignore it |
| 116 | if (incrementalListMember instanceof SfBoolean) { |
| 117 | result.setIncremental(((SfBoolean) incrementalListMember).getValue().booleanValue()); |
| 118 | } |
| 119 | |
| 120 | return result; |
| 121 | } |
| 122 | } |