Overall, I think this EIP’s stated goal of “determine the MIME type of a link” by using query parameters lacks clarity on how it’s helping the “auto” mode. The EIP does not describe a process that an implementing script could “automatically” follow, but rather seems to be just describing how a client can request an arbitrary format for the return value.
Notably, I think there needs to be separation between what the resulting data IS compared to what the requesting client is ASKING FOR. At a base level, all data can be transmitted as text/plain
, so at the base level the server can always assume it’s that format. I think what this EIP needs to lay out is a set of specific MIME types that an EIP4804-supporting server could implement to add more logic on top of just returning everything as text/plain
. It also should define the error-tolerance for adhering to the standard (similar to how a web browser as software has a set of MIME types it knows how to natively render rather than download, and it allows some tolerance for partially-broken implementations of those types).
I’d recommend this EIP cover text formats (plain, JSON, HTML, and XML), and image formats (SVG, PNG, JPG, GIF, BMP), and lay out a hierarchy of how a server is expected to determine what format the data is (e.g. start by assuming it’s plain text. First look for a comma in the data and see if what comes before it is a valid MIME-type. If it is, then parse as RFC 2397 to determine what format it is. If no comma, use magic bytes to guess what type it is: if it starts with a “<”, assume XML, and continue to parse to guess if it’s HTML, etc.). The result of that determining should set the Content-Type for the return value when no query parameters are set.
The query parameters then are there only for overrides needed in edge cases (e.g. the data is SVG, but the user pulling it up in a web browser wants to see the code, so requests text/plain
delivery).
If the current structure is desired to be kept, a few comments on the query parameters:
mime.dataurl=(true|false)
, which determines whether to decode the returned EVM data and set the MIME type according to data URL standard defined in RFC 2397. If the data cannot be parsed as data URL, an error will be returned.
How strict should the “cannot be parsed” be adhered to? Some contracts that use this structure don’t have data:
as a prefix before the data starts; should that result in an error being returned, or just parsing the rest of the string as following the rest of that format?
Being able to set ?mime.dataurl=false
seems to be a useless option? What behavior is the server supposed to take for that?
Having mime.type
as a separate query parameter seems like it’s a lot of extra boilerplate to do accessorizedImageOf/1289?mime.type=svg
compared to accessorizedImageOf/1289.svg
. Just using the file extension as an extension is more human-intuitive and an overall shorter URL. Is there a benefit to a more verbose query parameter?