[racket] web server: CRUD put/delete?

From: Jon Zeppieri (zeppieri at gmail.com)
Date: Thu Dec 4 23:54:08 EST 2014

The part about HTML forms is true. From the HTML 5 spec:
[https://html.spec.whatwg.org/multipage/forms.html#attr-fs-method].
There are also various discussions about this, like
[http://programmers.stackexchange.com/a/211790].

My XHR tests against Jay's code (using a Safari's JS console) work fine:

==========
> xhr = new XMLHttpRequest()
< XMLHttpRequest

> xhr.onreadystatechange = function() { if (this.readyState == 4) console.log(this.responseText); }
< function () { if (this.readyState == 4) console.log(this.responseText); }
> xhr.open("PUT", "http://localhost:6892/resources/spam")
< undefined
> xhr.send("STUFF")
< undefined
[Log] Resource updated.

> xhr.open("GET", "http://localhost:6892/resources/spam")
< undefined
> xhr.send()
< undefined
[Log] STUFF

> xhr.open("PUT", "http://localhost:6892/resources/spam")
< undefined
> xhr.send("MOAR STUFF")
< undefined
[Log] Resource updated.

> xhr.open("GET", "http://localhost:6892/resources/spam")
< undefined
> xhr.send()
< undefined
[Log] MOAR STUFF
==========

-Jon



On Thu, Dec 4, 2014 at 11:29 PM, George Neuner <gneuner2 at comcast.net> wrote:
> Hi Jon,
>
> On 12/4/2014 10:37 PM, Jon Zeppieri wrote:
>>
>> To my knowledge none of the major browsers support HTML forms using
>> anything but GET and POST. This is a user agent issue; not a server issue.
>> (Some frameworks use JS to intercept form submissions and perform them via
>> XHR, which can use other methods.) I haven't had a chance to take a close
>> look at your code, so I don't have anything to say about your attempts to
>> use XHR.
>
>
> Hmm.  If that's true it's very disappointing.  This is a database middleware
> app that's getting bigger by the hour (24 servlets and counting).  I
> certainly can get by with just GET and POST, but the servlet URLs will get
> long and (to me) unwieldy ... I was hoping to keep them short(er) with a
> CRUD interface, and also to test my servlets without too much Javascript  [
> browser programming being neither my forte nor my duty on this project ].
>
> There's still something bogus:  even with XHR, the right functions aren't
> being called.  DELETE works sometimes but sometimes not even twice in a row.
> PUT never works.  It may be a problem with how I'm using it ... but it's
> pretty simple and I've had no issues at all using GET or POST.  I'll have to
> get the browser guy to take a look at it.
>
> As  a certain bear said: "Oh, bother!!!"
>
> And Jay ... if this is all because I'm stupid, I apologize for wasting for
> your time.
>
> Thanks,
> George
>

Posted on the users mailing list.