Re: Is it correct to respond with partial representation for low capabilities media-types?

Will Hartung <[email protected]>
Newsgroups gmane.comp.web.services.rest
Message-ID <CAA2iDiAeZ-knQQqz=3nJ8eKnzKardhvyCzmMdUiar3JYp2LMQA@mail.gmail.com>
On Mon, Jun 4, 2012 at 7:38 PM, Philippe Rathé <[email protected]> wrote:

> **
>
>
> Hi,
>
> would it be correct for an application to provide partial resource
> representation when providing a certain media-type?
>
> My use case is that I have a user agent which don't have any
> formatting capabilities nor metadata capabilities. Would it be correct
> to "reserve" a specific media-type for that type of user agent so my
> application can skip the generation of a bunch of markup and metadata
> as a representation? And sometimes the reason is just that I don't
> want to exhaust the user agent.
>
Sure, why not?

Consider, say, BMP vs PNG, where BMP is basically a raw pixmap and PNG is
compressed. Here, since PNG is lossless, so there's not much of a
compromise in place unless the client simply can't decode PNG (always
possible).

But then consider BMP vs JPEG. JPEG is lossy, but the results are certainly
adequate for a lot of use cases.

Consider a low fidelity "mobile" representation. That seems completely
appropriate, don't you think?


> Are there any rules to follow when deciding to NOT include a specific
> part of a representation for a specific media-type? Like: "If the
> media-type can honor it you must include it"? Or judgment and best
> effort is enough?
>
The server lets the client know what's available, the client asks for what
it wants -- that's as basic a heuristic as you can get.

Obviously, especially in the case of mobile web, a lot of sites intuit what
it wants to deliver based on the Agent, rather than simply the content type
(since mobile browsers don't really look any different from desktop ones if
you look solely at content type). But that's really a browser limitation
combined with no real alternative data types (text/lite-html or something).

The real issue is that the content-type can not convey all of the desires
of the client. text/html is a perfectly adequate content type for both
mobile and 30" display, multi core, Gb networked workstations. Content type
can not, and should not, convey semantics -- it's simply not rich enough.
So then it need to become some other attribute of the request, for example:
http://example.com/resource?lightweight=true or something.

But using things like the Agent header I think is valid too to help drive
such decisions on the server.

And, of course, this is only for GETing representations -- this has nothing
to do with PUT or POSTing representations. That's a completely different
animal.

Regards,

Will Hartung
([email protected])

-- 
CONFIDENTIALITY NOTICE: The information contained in this electronic 
transmission may be confidential. If you are not an intended recipient, be 
aware that any disclosure, copying, distribution or use of the information 
contained in this transmission is prohibited and may be unlawful. If you 
have received this transmission in error, please notify us by email reply 
and then erase it from your computer system.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.