Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I think the most important distinction to remember between PUT vs. POST is that PUT is intended to be idempotent and POST is not.

    You should be able to PUT the same resource with the same data and it have no additional effect, after the first time.

    Remember also that the agent (client) submitting a PUT request should be able to tell if this is a new resource being created through the 201 response, although in practice this is heavily abused and many programs always return 200 responses for all success.
    • Yep, I forgot to mention this. An interesting thing about the idempotence discussion is that people confuse "I submit foo once or twenty times and get the same response" versus "I will have no side effects on the server from submitting foo."
  • I usually end up using POST for all CREATES, since I find no good way to pregenerate the URI to the thing I'm creating. Say you have a resource /videos which is the root to a listing of all the videos in your system. Each individual video might have a URI like /video/100, /video/110, etc. But if I want to create a new video using put I have to PUT the file to something like /video/120 but how do I know it's 120? Usually this ends up being autogenerated by a database anyway. So I find it most easy to PO
    --
    Waiting on the Road to Eventually, I lost my Place On Line
    • From what I've read the common thing to do is PUT to the 'collection' URI -- in your case, you'd do 'PUT /videos'; the server would return a '201 Created' header with the URI of the resource you just uploaded, like: '/video/110'.