Friday, June 27, 2014

web nerdz

Subject: web nerdz

  • note: originally emailed 06/27/2014 and sanitized for public consumption
  • sidenote: posting here so i can lead people here whenever they ask me about this stuff...


Many moons ago, I wrote the "http fun with telnet" post.


I think it needs to be revisited due to the renewed interest in 'standardized' REST calls (what web nerds say, "the way it was meant to be done")...


PUT vs POST

First, there's usually been some confusion with how REST calls are used --- in particular PUT vs POST.


Here are examples of what I mean:


But, really, a create/updating request should be thought of 'same thing'.


Note: PUT and DELETE are normally not enabled on all web servers



Server side processing

Because PUT and DELETE are quite dangerous if not controlled, server side processing (PHP, ASP, etc.) handled much of the PUT/DELETE (i.e. create, update, destroy) processes by incorporating them with AJAXy APIs (normally done with GET and POST only).


Let's see an example of the "server side processing" that a lot of people are used to:

Here, the action parameter is descriptive, to the point and clear on intention.


I do realize that the URL "parameters" are much more descriptive than 'PUT'...
  • But, you'll need to see what is 'implied' when using GET/PUT/POST...



Idempotent Retries

There's a very important concept for web server technologies that needs to be understood before continuing



Pretty URLs

A lot of web nerds want to slim down the URL so that search engines can "crawl" your web site with impunity.


Anyways, back to the implied usage of GET/PUT/POST/DELETE (what they call HTTP verbs). Let's take a look at an example URI:
  • http://webserver/account/nick
    • GET would return my details
    • PUT could update my details
    • A first time POST would create my account
    • And of course, DELETE would disable or nuke my account
  • Note that each of the methods does different things while the URL stays the same

You can still use server side processing to handle this
  • For example, in: http://webserver/account/
    • The index page has been setup as "app.php"
    • app.php will process (for example) /account/nick as the ARGs for the script (and any POST or URL parameters) to handle the request

  • you can look at (http_fun_with_telnet) and add handlers for PUT and DELETE to complete this homework assignment

No comments: