Hi Marcel,

Is it conforming to the REST philosophy to use key/values in the URL?


It's not stupid, nor easily answered.  Perhaps have a look at this post:

http://article.gmane.org/gmane.comp.java.restlet/5440


> http://www.x.com/serv/location?user=joe&passwd=bla&lat=4.132&lon=8.4559
>
> and further, how can I force a POST when i copy/paste the above
> into my Firefox url field?


You cannot.  Entering a URL into the field causes a GET request.  To make a
POST, you must be submitting a form or using Javascript to make the browser
do a POST.


> As the above does an upload of lat/lon it should be a POST, shouldn't it?


It would be better as a POST.  If you are linguistically inclined, you can
think of HTTP requests as sentences.  The type of request (GET, POST, etc)
is the verb, the entity as the direct object, and the URL as the indirect
object.  Refresher: in "Give the dog a ball" -- give is the verb, ball is
the direct object, dog is the indirect object.

GET requests typically have an empty entity; a null direct object.  GET
[whatever is there] from /my/url

POST requests have an entity containing something -- it could be parameters,
XML, JSON, mime-encoded files, whatever.  POST [this data] to /my/url

This is part of why query parameters in the URL seem simple but actually end
up being confusing.  Not that it's wrong, or illegal, or non-RESTful, or any
other pejorative term ... it's just harder to reason about what is going
on.  Especially because you may use some of those query parameters as
imperative verbs (action=delete) some as variables (lat=4.132), etc.  Now it
is not clear whether you mean the HTTP verb (GET) or your own verb "delete"
... and it's not clear whether you mean for me to look at what's in the
entity, or what's on the query string, or both.

I prefer architectures that don't work this way.  If you have data you need
to supply (lat and lon) I would rather use a URL structure like

/serv/location/{lat}/{long}
or -- I think better:
/serv/location/{space-separated-latlong}
since this does not imply hierarchy where there is not necessarily any.

Or if you support different types of location,

/serv/location/latlong/{latlong}
/serv/location/postcode/{postcode}

POST or PUT something to /serv/location/latlong/4.132+8.4559 would store
something at this location.  GET something from
/serv/location/latlong/4.132+8.4559 would get the current value of this
location.  The thing you GET and the thing you PUT (whether it is XML or
JSON or whatever) should be the same thing.  The thing you POST may be
different, because the semantics of POST imply that some interpretation is
being done by the server -- that's why it's not a PUT.

And finally, why does Firefox remove the credentials in this case:
>
>  http://joe:[EMAIL PROTECTED]/serv/location?lat=4.132&lon=8.4559
>

Stephan got it.

- Rob

Reply via email to