OK, I want to talk a little bit more about why HTTP forms cannot submit, like PUT and DELETE requests. Why...
are we only limited to GET and POST?
I'm just ignoring dialog, by the way.
But why are we limited 🤷🏻‍♂️?
It's so weird, right?
Well, firstly, I want to say that HTML is inextricably bound to HTTP.
HTML is kind of just like the human interface of HTTP.
Remember that HTTP is just the protocol that allows machines to speak to each other.
And HTML, of course is that visual representation to us.
And this means it's questionable why HTML does not support all the relevant methods that you can find
in the HTTP specification.
In other words, why can machines PUT and DELETE resources but humans can't 🤔?
We can't do it in our code.
Well, it's a great question.
And let me just clarify by saying that browsers themselves do understand and support PUT and DELETE.
It's only the HTML protocol for forms which does not allow it.
For instance, a browser will initiate a POST requests via AJAX, but it just won't do it via an HTML
form.
"Okay Clyde, that's cool...
but why is this?"
Well, that is a very, very good question.
And I had to do a lot of digging around, a lot of reading to find out why this is the case.
Not many people know about this and this information was very hard for me to find.
As it turns out, PUT and DELETE methods were included in drafts in the early HTML5 spec.
I know,
weird, right?
But they were later removed in subsequent drafts.
Mozilla had actually implemented these methods in their browser, their meta browser in Firefox, but again
later removed.
What was the rationale for removing these from the specs and who decided to remove it from the specs?
Well, that comes down to the W3C - the World Wide Web Consortium.
They decided to remove them from the spec. The W3C by the way is just an organization that governs
web.
And after tons and tons of digging ⛏️, I managed to find a discussion that took place by the W3C forum
all the way back in 2010 in bug report 10671, in case you're interested.
And in this discussion, there were tons of developers that were in support of using alternative methods
other than just GET or POST.
And let me just say that GET and POST have a clear, content neutral rationale.
GET is used to retrieve the content of a URL that is safe to repeat and possibly even cache.
And you typically use POST when the data may not be safe to repeat, execute speculatively or even cache.
We've seen this. We know this already. And during these discussions on this forum...
about this bug 🐛, people couldn't really find a rationale for including PUT or DELETE.
Because PUTs and DELETEs are pretty much covered by the POST request.
Creating or destroying data in a POST, for example, is not something that's safe,
it's not something you want to cache or repeat.
And what these developers were saying was that there's not really, therefore, a need to semantically
differentiate, a PUT and DELETE from POST when it comes to HTML submissions.
In other words, they were saying there is no semantic benefit. Whew. So you had a lot of people on the...
one side saying that, you know, it makes sense to have a PUT and DELETE.
Then you had all these developers on the other side saying, well, semantically it doesn't really make
sense.
It's just the same as a POST request.
And of course, after much debate, that forum, or...
that bug 🐛, was closed.
And this question was opened up on another forum known as the HTML Working Group Forum, and it had an issue...
number of 195, just in case you are wondering.
And this issue - 195 - was presented to the chairs of the committee.
It was presented to a gentleman called Cameron Jones who stepped up to the plate and he said he would...
draft a proposal, which he did on the 29th of May 2014.
And this draft that was submitted on the 29th of May 2014 hasn't really gone anywhere.
So I don't know. At the moment...
we're kind of sitting in a bit of flux, um, where we've got GET and POST.
We've got dialog,
yes...
but the main ones are GET and POST. And you've got a whole lot of people on the one hand wanting to endorse
other methods like PUT and DELETE.
And then you've got other arguments on the other hand, where the developers are just saying, just...
treat it as a POST request, who cares!
And the working draft is kind of just still sitting there.
Nothing's really been done about it.
And perhaps the only reason why we don't have PUTs and DELETEs and other methods is that no one really
has time to fully devote to writing a specification defining all of this.
So there you go. I hope you find that very interesting.
You know, a lot of people spend most of their, if not all of their coding career not understanding exactly...
why the HTML spec does not have other methods.
So, there you go...
just in case you were wondering. See you in the next letter 👋.