Free Newsletters
Technology & Business Daily

InfoWorld
Log-in | Register
STRATEGIC DEVELOPER  

End HTTP abuse

Web access toolkits should make it easier to do the right thing

By Jon Udell  
April 20, 2005
 

You'd think that a language with a mere handful of verbs, only two of which are widely spoken, would be easy to learn. Not so in the case of the HTTP, though. After more than a decade, we're still sorting out how and why to use its most common verbs: GET and POST.

Free IT resource

TechNet: More ways to know it, share it, and keep it running.

Sponsored by Microsoft

Free IT resource

Attend the SOA Executive Forum: Breaking SOA Bottlenecks SOAExecForum.com/may2007

Sponsored by InfoWorld

This perennial issue recently flared up again when Microsoft's Dare Obasanjo noted that three popular services had got it wrong. Bloglines, Flickr, and del.icio.us all offer APIs that claim to be RESTful -- that is, to conform to the Representational State Transfer principles of HTTP -- yet each violates those principles by allowing GET in some cases where only POST should be allowed.

There are two reasons why a service ought to allow HTTP GET, when it's appropriate to do so. First, the resulting URL remains visible in the browser's address (location) field. That means you can bookmark a request, post it to the Web, or send it to someone in an e-mail. If you've ever wanted to save a search but couldn't, the reason is probably that the form unnecessarily used POST rather than GET.

A second rationale for GET is that various systems along an HTTP pipeline may be able to cache the response.

GET's purpose, however, is only to retrieve information. When you offer a service that updates a resource, you should disallow GET and require clients to use POST. (There are also rarely used HTTP verbs to PUT or DELETE resources, but that's another story.) The reasoning here is twofold: You don't want users to invoke resource-altering requests from hyperlinks. And, such requests aren't cacheable.

Why didn't Bloglines, Flickr, or del.icio.us enforce the POST restriction? I suspect it's because they wanted their APIs to have the broadest possible reach. And from a programmer's perspective, the simplest and easiest HTTP clients are those that use GET.

As an experiment, I sent both GET and POST requests to one of the indicted APIs using four different HTTP client technologies. First up was Curl, the Swiss-army knife of command-line-based URL fetchers. In this case, happily, it was trivial to convert a GET-style request to one that uses POST. I just took the part of the URL that followed the question mark and stuck it after a -d flag. I might have had to look that up, but it's only a small step off the path of least resistance.

The same held true for Python's basic one-line URL fetcher, urllib. In this case I took what followed the URL's question mark and attached it to the optional data argument. Again, just a small extra step.

With Perl, though, I had to take a bigger step. Perl's basic one-line URL fetcher is implemented by the LWP::Simple module. But to switch from GET to POST, I had to construct an LWP::UserAgent object, call its post method, and encode the arguments in a data structure.

Likewise with JavaScript. I could issue a GET request by simply assigning a URL to the location.href object. To issue a POST, though, I had to construct a form or use the nonstandard XMLHttpRequest object.

These aren't huge obstacles. But if all toolkits made POST as accessible as GET -- or as nearly so as possible -- there would be less incentive to misuse GET.

It should be easy to do the right thing.





 


 
Jon Udell is lead analyst and blogger in chief at the InfoWorld Test Center.

  More of Jon Udell's column
  Jon Udell's Weblog

Newsletter Check out all of our free newsletters!
Enter e-mail address:




 

TOP NEWS:


»  Think small with Linutop 2 PC
The tiny, energy-efficient Linux-based Linutop 2 is a low-cost, minimalist PC that is eerily quiet to use

»  Sun technologist: SOAP stack a 'failure'
Tim Bray, co-inventor of XML, prefers REST mechanism over SOAP

»  Software piracy hurts the open-source community too
Many nations are beginning to see stolen proprietary software as a lost opportunity for open source software, whose development can encourage innovation and job growth

»  Intel readies slew of embedded chips based on Atom core
Intel is trying to increase performance and drop power consumption in more than 15 system-on-chips that use the Atom core

»  Microsoft surprise reorganization aimed at online woes
Microsoft's online troubles hint at larger vulnerability; the company is facing challenges in areas that have been a lock for many years

»  Attack code released for DNS bug
Security experts warn that this attack code may give cybercriminals a way to launch virtually undetectable phishing attacks




Virtualization: A Step by Step Approach to Success
Your virtual machines can be up and running in a matter of minutes. HP and Citrix have integrated XenServer with HP ProLiant servers and management tools, powered by hardware-assisted Intel Virtualization Technology to enable high- performance, cost-savings solutions for server consolidation and disaster recovery. Sponsor: HP

»  Click here to view this Webcast
  Zombie PCs Are Attacking Your LAN
A recent study showed that malware-infected zombie PCs are now a bigger threat to ISPs and Web infrastructure than DoS attacks. As this brand new IT Strategy Guide explains, an increased use of peer-to-peer techniques by the attackers has made it harder to fight back. Download now, compliments of Verio:

»  Click here to download now

- Special Advertising Partners -
WHITE PAPERS
 

» Technology White Papers Library

Technology White Papers by Topic

Technology White Papers E-mail Alert

Find out when the latest white paper is available:
 
 
INFOWORLD MARKETPLACE
 
» BUY A LINK NOW
 

FIND PRODUCTS AND COMPANIES
» COMPLETE PRODUCT GUIDE



TECHNOLOGY INDEX
• Applications
• Application Development
• Security
• Networking
• Wireless
• Platforms
• Hardware
• Data Management
• Storage
• Web Services
• Business
• Telecom
• Professional Services
• Standards

TECH WATCH 


What's the 411 on GOOG-411?
Just as Google has become synonymous with "performing a Web search," 411 is understood to mean "information" -- as in "what's the 411?" I was thus surprised to discover, from a billboard, no less, that the king of search is taking on the ...

Apple HTML source reveals 'iPhone Extreme'
"This one's a stretch..." reports AppleInsider. Um, yeah. Reporting on HTML code sightings of product names could be called a stretch, but iPhone Extreme has a ring to it. Now, that sounds like the product Apple should have released first, rather ...

COLUMNISTS

Unified under law
Ephraim Schwartz's Column and Blog (InfoWorld) - In the litigious world we live in, deploying a unified communications platform in your enterprise could...
» MORE COLUMNISTS

MORE INFOWORLD BLOGS


Open Sources 
Product Management
When I joined MySQL four years ago, there was quite a lot of debate about product management. We didn't actually have ...

Zero Day 
Botnet herders tending smaller flocks
New research backs up the theory that botnet operators are keeping their networks smaller in a continued effort to keep ...



• Advice Line
• Database Underground
• The Deep End
• Enterprise Mac
• Geeks in Paradise
• Grid Meter
• The Gripe Line
• InfoWorld Daily
• Inside IT
• IT Troubleshooter
• ITXtreme
• Open Sources
• ProdBlog
• Real World SOA
• Reality Check
• Security Adviser
• SMB IT
• The Storage Network
• Tech Watch
• Virtualization Report
• Zero Day

ADVERTISEMENT


RESOURCE CENTERadvertisement 

GOVERNMENT IT & POLICY
'If you don't go after the network, you're never going to stop these guys. Never.'
From the State Department, All the News for Inquiring Minds
TechPresident, the Internet Citizenry's New Consensus Taker



Sponsored Technology Links

 
 
 HOME  NEWS  BLOGS  PODCASTS  VIDEOS  TECHNOLOGIES  TEST CENTER  EVENTS  CAREERS   About | Advertise | Awards | RSS | Contact Us 

Copyright © 2008, Reprints, Permissions, Licensing, IDG Network, Privacy Policy, Terms of Service.
All Rights reserved. InfoWorld is a leading publisher of technology information and product reviews on topics including viruses,
phishing, worms, firewalls, security, servers, storage, networking, wireless, databases, and web services.

CIO :: ComputerWorld :: CSO :: Demo :: GamePro :: Games.net :: IDG Connect :: IDG World Expo
Industry Standard :: IT World :: JavaWorld :: LinuxWorld :: MacUser :: Macworld :: Network World :: PC World :: Playlist