UserPreferences

PaceCollectionsAcceptedMediaTypes


Abstract

Adds a mean of identifying a collection's allowed resource media types from within the Introspection Document.

Status

Open (ThomasBroyer)

Rationale

Within the current protocol draft (06), you can't know whether you can POST a resource of a given media type to a Collection Resource: you must try and see if you get an error (415 Unsupported Media Type).
In an APP client, such an information could prevents the user from selecting an unaccepted file. E.g. if a collection only accepts image/* resources, the APP client can prevent the user from selecting an Office document.
In comparison, HTML4 forms and XForms both provide that information for file uploads (see the References section below), respectively through their accept (on the form and input type="file" elements) and mediatype (on the upload element) attributes.

Proposal

Add a accept attribute to the app:collection element in Introspection Documents.

In section 8.1.1.3 The 'app:collection' Element, update the RNC:

appCollection =
   element app:collection {
      appCommonAttributes,
      attribute title { text },
      attribute href { text },
      attribute accept { text },
      ( appMemberType
        & appListTemplate
        & extensionElement* )
   }

Add a new section:

8.1.1.3.2  The 'accept' Attribute

   The 'accept' attribute identifies the allowed content type(s) of
   the collection's member resources. Its value is a comma-separated
   list of media ranges with optional parameters, as defined in section
   14.1 of [RFC2616] as the field value of the accept request header.

   During an HTTP POST, the Collection Resource MUST accept any resource
   whose media type matches the 'accept' value specified in the
   Introspection Document and therefore MUST NOT respond with a 415
   Unsupported Media Type status code. It MAY however reject a resource
   whose media type is allowed for other reasons, e.g. if it is not
   well-formed or otherwise doesn't match other prerequisits.

   If the app:member-type element has a value of "entry", the collection
   MUST allow editing of "application/atom+xml" resources, i.e. the
   value of the 'accept' attribute MUST match the "application/atom+xml"
   media type, either using the media type directly or through a media
   range such as "application/*" or "*/*".

Impacts

APP clients can avoid POSTing resources to a Collection Resource if they know it doesn't accept resources of that media type. They can also avoid GETting collections or their members if they don't support the collection's member media types.
By extension, APP clients can prevent users from selecting resources of an unaccepted media type for POSting to a Collection Resource; or they can warn the user before GETting a collection or its members if they don't support the collection's member media types.

Notes

References


CategoryProposals