HPInc / jipp

A Java-compatible implementation of IPP
MIT License
153 stars 42 forks source link

Make it easier to get attribute order correct #77

Closed GladeDiviney closed 4 years ago

GladeDiviney commented 4 years ago

https://tools.ietf.org/html/rfc8011#section-4.1.4 specifies required ordering for attributes-charset, attributes-natural-language, *-uri and job-id attributes.

But groupOf, while flexible, allows you to toss any old order in there.

Let's add these to the DSL:

operationGroupOf("us-en", "utf-8", ...others)
uriOperationGroupOf("us-en", "utf-8", printerUri.of(uri), ...others)
jobOperationGroupOf("us-en", "utf-8", jobUri, jobId, ...others)

An error would be thrown if the "others" attributes were to contain attributes-charset, attributes-natural-language, or any out-of-order -uri attributes.

GladeDiviney commented 4 years ago

Another idea from #58 is to add a priority to each attribute type, but ordering requirements only apply to the operation group, and only to tiny fraction of available attributes. So a few special-case builders are perhaps a simpler approach.

gmuth commented 4 years ago

I think only attributes-charset and attributes-natural-language needs be taken care of (1st and 2nd). Otherwise the order should not have an impact. You should handle those attribute values more specific anyway. To me it makes sense to exclude them from the generic handling.

GladeDiviney commented 4 years ago

In theory, I agree with you on attributes-charset. In practice, are there really implementations that don't use utf-8? Seems pretty ubiquitous these days, and it's required for both clients and printers as per https://tools.ietf.org/html/rfc8011#section-4.1.4.1.