Anne van Kesteren

The method argument of the open method

Please pay attention, the first “method” here is a reference to an argument that happens to be called that way. The second “method” is about open, an actual method, as yeary is in x.yeary("anne",20060801). (“yeary” is the unexisting English word meaning “jarig,” a Dutch word without translation. No, it does not mean “one year old,” smart ass.) Anyway, this post is supposed to be about XMLHttpRequest; more specifically, its open method. Gorm “Opera Platform” Haug Eriksen did some browser testing and the results are discturbing (other people helped out too, see the related e-mails from ISSUE-75).

So from what I heard so-called REST people like to use arbitrary method names, open('donkey', uri) and such. From what I read method names are case-sensitive. Internet Explorer, Firefox and Opera implement method names case-insensitive (details vary). Firefox and Internet Explorer allow arbitrary method names (following the rules of some known method I assume, but I’m unsure which) as opposed to Opera and Internet Explorer 7 which disallow them. Fun. Now what I’d like to know is how much content uses GET and POST in the wrong canonical form to see if we can stop violating the HTTP specification. (Yes, I know the specification has examples with get instead of GET. I’ll fix that.)

Writing this up I very much agree with Paul Graham, blogging is about thinking out loud. (Not literally what he said…) And you know what, we all love innerHTML, not? Good way to end this post.

Comments

  1. That's a disturbing question. Unfortunately, checking the various things I've touched which use XMLHttpRequest, I have bad news... prototype.js (which I had the misfortune to have to debug problems in recently) uses lowercase "get" and "post".

    snipping from the source:

    setOptions: function(options) {
        this.options = {
          method:       'post',
          asynchronous: true,
          contentType:  'application/x-www-form-urlencoded',
          parameters:   ''
        }
    
    this.transport.open(this.options.method, this.url,
            this.options.asynchronous);

    Posted by Sander at

  2. Randomly looking at various frameworks: Sajax, Atlas, MochiKit, dojo, Freja, Backbase, activewidgets, xajax and ajaxCFC appear to be safe, but Zimbra uses lowercase as well:

    this._httpReq.open((useGet)?"get":"post"

    (Heh, and then there's AjaxFace, which seems to have integrated an obfuscated version of prototype (and so probably uses lowercase as well, but I'm not going to bother to de-obfuscate and say for certain). But it's probably indicative that there's lots of other frameworks integrating prototype (indeed just found symphony doing that).)

    Posted by Sander at