Search the web
Sign In
New User? Sign Up
rest-discuss · REST Discussion Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Using HTTP Link: headers for web linking non-hypertext   Message List  
Reply | Forward Message #13046 of 14330 |
Fwd: [rest-discuss] Using HTTP Link: headers for web linking non-hypertext

Hi Subbu-

1. The server has a cart resource, and product resources.

2. Each product resource found in a search will have a link

<link rel="http://shop.org/rels/buy" href="http://shop.org/subbu/cart"/>

The definition of rel says that the client should use POST to add the product to the cart.

3. Client adds the product to the cart

POST /subbu/cart
Content-Type: application/xml

id=1234

4. Server redirects back to the updated cart

303 See Other
Location: http://shop.org/subbu/cart


This looks just right for a one-many link (as in my #1 option -- post to a cart "collection" resource) in which the "one" is obvious and easily discoverable (like a cart).  But a common case I run into is a one in which a resource must be linked to any of a large number of possible related resources.  (In my case it is a digital image library, in which we regularly need to create links between items, e.g., a link from a photo of an architect to an image of a building that she created.).  We have needed to devise as general an operation as possible to *relate* two resources.  In the case of a cart and a product, it is obvious what the relationship will be once it is created.  We have need to create links between resources that may have any of a large number of relations (e.g., "created-by").  I wish to stay in the realm of Atom (avoiding complexities of RDF).  I am reminded somewhat here by the work going on in activities streams....  Anyway, I agree with Sam that it is currently an unsolved problem with wide applicability.

--peter


 

This is just generalized version of a web based shopping cart, and provides a simplified interface to the client. As I said before, expecting the client to manage links is akin to clients posting SQL statements to servers.

Subbu



On Tue, Jun 30, 2009 at 11:59 AM, Subbu Allamaraju <subbu@...> wrote:



Sam,

I don't disagree that there are use cases, but I am not sure if
letting clients manage relations is the right way to implement
distributed systems. The approach you describe below is similar to a
client trying to setup foreign key relations between different
database entities. This model leaks abstractions and is not ideal for
writing large systems.

For instance, take a simple shopping cart application. The server may
have decided to use links to associate products to a cart, but that
does not mean that, clients should be able to create/edit/delete those
links. Instead, links come into being when the client "adds products
to a cart" and they go away when the client "removes a product from
the cart". That is the right level of abstraction for the client.







IMO, links are for servers to provide navigability between resources,
and to let clients make state transitions via links.

Subbu


On Jun 30, 2009, at 3:44 AM, Sam Johnston wrote:

Hi Subbu,

On Tue, Jun 30, 2009 at 5:45 AM, Subbu Allamaraju <subbu@...<subbu%40subbu.org>>

wrote:

LINK is similar - how a LINK relationship is created/managed/
destroyed is
undefined.

Why isn't that up to the server(s) managing the resources? Links are
for servers to describe relations between resources, and not for
clients to manage such relationships.


Why so? This use case requires that clients be able to manage links:
virtual
infrastructure is modeled as compute, storage and network resources
and
clients create, delete and link them as they see fit. The server can
too
(for example, implicitly creating a storage resource and linking it
when you
create a compute resource) but the point of OCCI
<http://www.occi-wg.org/>is to allow for client manipulation.

We're not the only ones who see a need either... the original
authors of the
HTTP spec (RFC 2068) including LINK and
UNLINK<http://tools.ietf.org/html/rfc2068#section-19.6.1.2>verbs for
this around the same as this
I-D <
http://ftp.ics.uci.edu/pub/ietf/http/draft-pritchard-http-links-00.txt
specifying
same in more detail. This is what Mark Nottingham (author of the
Link: header I-D among other things, copied) had to say this morning
on
apps-discuss:

*- First and foremost, in the absence of the LINK and UNLINK verbs
originally defined in RFC 2068[2] but specifically omitted from RFC
2616[3],
what is the preferred mechanism for manipulating these links via
HTTP? It
appears that this header is intended for GET requests only, but
presumably
specifying it in POST and PUT requests would be one option that
avoids the
creation of [not so] "new" verbs (bearing in mind that short of
accepting
Link: headers from empty POST/PUT requests, it would be necessary to
GET and
then PUT the entire payload to update links - twice if they were
reciprocal). While there was an attempt a dozen years ago to better
define
the relevant HTTP verbs[4], it strikes me as more sensible to follow
the
example of the Set-Cookie: header for this rather than WebDAV's
example of
creating new verbs (even if we've seen them before) but you guys are
the
experts.*

Undefined, but I imagine in a PUT/POST body does indeed make the
most sense.
Using the Link header in a request doesn't have well-defined
semantics.

I wonder then whether it's not sensible to define these semantics in
an[other] Internet Draft (ala Set-Cookie) rather than having everyone
running off and inventing their own in-band solutions... doing so
would make
for some really clever RESTful interfaces.

Sam







Tue Jun 30, 2009 8:28 pm

pkeane_littl...
Offline Offline
Send Email Send Email

Forward
Message #13046 of 14330 |
Expand Messages Author Sort by Date

... They (browsers) do not. But that is besides the point for this thread. The key question being debated is whether link management is a client concern or it...
Subbu Allamaraju
sallamar
Offline Send Email
Jul 1, 2009
4:37 pm

... Ok so here's a separate but similar issue. I've just released an Internet-Draft...
Sam Johnston
sam.johnston...
Offline Send Email
Jul 1, 2009
11:18 pm

... The point is you don't have to be able to create links to consume them and vice versa. Both servers and clients create links and there seems little point...
Sam Johnston
sam.johnston...
Offline Send Email
Jul 1, 2009
4:35 pm

Hi Subbu- ... This looks just right for a one-many link (as in my #1 option -- post to a cart "collection" resource) in which the "one" is obvious and easily ...
Peter Keane
pkeane_littl...
Offline Send Email
Jun 30, 2009
8:29 pm

Peter, ... This is a great use case - thanks a lot. ... I'm going one step further in eliminating the Atom for individual resources. That would allow you...
Sam Johnston
sam.johnston...
Offline Send Email
Jun 30, 2009
8:50 pm

... So, when you let clients establish links between resources, who controls whether a link is valid or bogus? What is the advantage of the client owning this...
Subbu Allamaraju
sallamar
Offline Send Email
Jun 30, 2009
10:26 pm

... Good questions. Certainly, it'll be the server that controls what's a valid "linkage", but the range of possibilities might be (nearly) infinite. And I ...
Peter Keane
pkeane_littl...
Offline Send Email
Jul 1, 2009
1:33 am

FWIW, Link *Headers* make sense to me when the link are metadata about the resource. However, when the links are to be treated as first-class resources ...
mike amundsen
mamund
Offline Send Email
Jul 1, 2009
3:02 am

I agree with mike. IMHO, it seems it is here a meta level problem w.r.t. the application vs. protocol POV. Taking the building/architect example, the architect...
Yannick Loiseau
pioupiougroups
Offline Send Email
Jul 1, 2009
9:49 am

Yannick, Does this not strike you as far more complicated than necessary? Under your proposal I need to do a bunch of requests and understand a new language...
Sam Johnston
sam.johnston...
Offline Send Email
Jul 1, 2009
1:46 pm

... Indeed, this is a little overhead since here I modeled a one-to-many (or many-to-many as suggested before) relationship, and added more semantic than...
Yannick Loiseau
pioupiougroups
Offline Send Email
Jul 1, 2009
3:38 pm

... Do you mean like this? GET /cart "cart" : {... , "products": [], .... } adding products: PUT /cart "cart": {..., "products": [ "/products/143",...
Mike Kelly
pleb1985
Offline Send Email
Jul 1, 2009
2:24 pm

... Mike- Yes, that's basically what I was proposing. (I was thinking specifically in terms of Atom, but the GET/EDIT/PUT pattern is exactly the approach I...
Peter Keane
pkeane_littl...
Offline Send Email
Jul 1, 2009
4:28 pm

... Let's leave aside the issue on whether to introduce LINK and UNLINK. What about the value of Link headers themselves? I really like the idea of...
Bill Burke
patriot1burke
Online Now Send Email
Jul 1, 2009
12:26 pm

What is "polluting" about links? I suspect that you are talking about adding links to an object serialized into XML is polluting the representation. But is...
Subbu Allamaraju
sallamar
Offline Send Email
Jul 1, 2009
1:09 pm

Subbu, I'm thinking more of the case where you have more generic services that need to know about certain relationships but don't understand the data format. ...
Bill Burke
patriot1burke
Online Now Send Email
Jul 1, 2009
1:41 pm

Exactly - it's about making non-hypertext resources first class citizens on the Internet in an intuitive, RESTful manner. Sure I could base64 encode them and...
Sam Johnston
sam.johnston...
Offline Send Email
Jul 1, 2009
1:57 pm

I'm thinking even for hypertext-based resources you'd want link headers. Headers seem much much more simpler than requiring a envelope format like Atom. ... --...
Bill Burke
patriot1burke
Online Now Send Email
Jul 1, 2009
2:10 pm

Ah. That makes sense. (To fully take advantage of these headers and entity headers in general, client APIs will need to start including headers as part of...
Subbu Allamaraju
sallamar
Offline Send Email
Jul 1, 2009
2:31 pm

... Ditto - the question was about devising a "means to manage the implied relationship". The designers of HTTP planned to do it with LINK and UNLINK, but I...
Sam Johnston
sam.johnston...
Offline Send Email
Jun 26, 2009
1:29 pm

... Its not just about raw performance though. There's also a barrier to entry problem very similar to SOAP and CORBA. Before I heard about Atom, one of the...
Bill Burke
patriot1burke
Online Now Send Email
Jun 26, 2009
2:39 pm
 First  |  |  Next > Last 
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help