WEBVTT

0
00:00.720 --> 00:11.490
OK, I want to talk a little bit more about why HTTP forms cannot submit, like PUT and DELETE requests. Why...

1
00:11.490 --> 00:14.040
are we only limited to GET and POST?

2
00:14.550 --> 00:16.170
I'm just ignoring dialog, by the way.

3
00:16.650 --> 00:17.670
But why are we limited 🤷🏻‍♂️?

4
00:17.690 --> 00:18.630
It's so weird, right?

5
00:19.230 --> 00:26.100
Well, firstly, I want to say that HTML is inextricably bound to HTTP.

6
00:26.320 --> 00:31.400
HTML is kind of just like the human interface of HTTP.

7
00:31.710 --> 00:36.150
Remember that HTTP is just the protocol that allows machines to speak to each other.

8
00:36.390 --> 00:39.690
And HTML, of course is that visual representation to us.

9
00:39.960 --> 00:46.560
And this means it's questionable why HTML does not support all the relevant methods that you can find

10
00:46.560 --> 00:48.900
in the HTTP specification.

11
00:49.150 --> 00:55.290
In other words, why can machines PUT and DELETE resources but humans can't 🤔?

12
00:55.290 --> 00:56.610
We can't do it in our code.

13
00:57.630 --> 00:58.590
Well, it's a great question.

14
00:58.980 --> 01:06.210
And let me just clarify by saying that browsers themselves do understand and support PUT and DELETE.

15
01:06.360 --> 01:10.980
It's only the HTML protocol for forms which does not allow it.

16
01:11.220 --> 01:18.180
For instance, a browser will initiate a POST requests via AJAX, but it just won't do it via an HTML

17
01:18.180 --> 01:18.670
form.

18
01:19.450 --> 01:20.400
"Okay Clyde, that's cool...

19
01:20.400 --> 01:21.480
but why is this?"

20
01:21.720 --> 01:23.760
Well, that is a very, very good question.

21
01:24.330 --> 01:29.420
And I had to do a lot of digging around, a lot of reading to find out why this is the case.

22
01:29.430 --> 01:33.270
Not many people know about this and this information was very hard for me to find.

23
01:33.570 --> 01:40.800
As it turns out, PUT and DELETE methods were included in drafts in the early HTML5 spec.

24
01:41.040 --> 01:41.460
I know,

25
01:41.590 --> 01:42.120
weird, right?

26
01:42.120 --> 01:44.940
But they were later removed in subsequent drafts.

27
01:45.180 --> 01:52.500
Mozilla had actually implemented these methods in their browser, their meta browser in Firefox, but again

28
01:52.590 --> 01:53.610
later removed.

29
01:53.940 --> 01:59.370
What was the rationale for removing these from the specs and who decided to remove it from the specs?

30
01:59.730 --> 02:04.080
Well, that comes down to the W3C - the World Wide Web Consortium.

31
02:04.320 --> 02:09.900
They decided to remove them from the spec. The W3C by the way is just an organization that governs

32
02:09.930 --> 02:10.520
web. 

33
02:10.590 --> 02:17.130
And after tons and tons of digging ⛏️, I managed to find a discussion that took place by the W3C forum

34
02:17.550 --> 02:24.810
all the way back in 2010 in bug report 10671, in case you're interested.

35
02:25.110 --> 02:29.850
And in this discussion, there were tons of developers that were in support of using alternative methods

36
02:29.850 --> 02:31.080
other than just GET or POST. 

37
02:31.500 --> 02:36.350
And let me just say that GET and POST have a clear, content neutral rationale.

38
02:36.660 --> 02:43.020
GET is used to retrieve the content of a URL that is safe to repeat and possibly even cache.

39
02:43.200 --> 02:50.960
And you typically use POST when the data may not be safe to repeat, execute speculatively or even cache.

40
02:51.270 --> 02:55.410
We've seen this. We know this already. And during these discussions on this forum...

41
02:55.410 --> 03:00.210
about this bug 🐛, people couldn't really find a rationale for including PUT or DELETE. 

42
03:01.620 --> 03:06.060
Because PUTs and DELETEs are pretty much covered by the POST request.

43
03:10.720 --> 03:17.380
Creating or destroying data in a POST, for example, is not something that's safe,

44
03:17.410 --> 03:19.420
it's not something you want to cache or repeat.

45
03:19.960 --> 03:24.400
And what these developers were saying was that there's not really, therefore, a need to semantically

46
03:24.610 --> 03:29.800
differentiate, a PUT and DELETE from POST when it comes to HTML submissions.

47
03:30.960 --> 03:35.250
In other words, they were saying there is no semantic benefit. Whew. So you had a lot of people on the...

48
03:35.250 --> 03:39.290
one side saying that, you know, it makes sense to have a PUT and DELETE. 

49
03:39.300 --> 03:42.930
Then you had all these developers on the other side saying, well, semantically it doesn't really make

50
03:42.930 --> 03:43.230
sense.

51
03:43.240 --> 03:45.030
It's just the same as a POST request.

52
03:45.270 --> 03:48.260
And of course, after much debate, that forum, or...

53
03:48.330 --> 03:49.890
that bug 🐛, was closed.

54
03:50.520 --> 03:56.760
And this question was opened up on another forum known as the HTML Working Group Forum, and it had an issue...

55
03:56.760 --> 03:59.370
number of 195, just in case you are wondering.

56
03:59.580 --> 04:03.150
And this issue - 195 - was presented to the chairs of the committee.

57
04:03.150 --> 04:08.970
It was presented to a gentleman called Cameron Jones who stepped up to the plate and he said he would...

58
04:08.970 --> 04:13.740
draft a proposal, which he did on the 29th of May 2014.

59
04:13.960 --> 04:19.190
And this draft that was submitted on the 29th of May 2014 hasn't really gone anywhere.

60
04:19.800 --> 04:21.120
So I don't know. At the moment...

61
04:21.120 --> 04:26.190
we're kind of sitting in a bit of flux, um, where we've got GET and POST. 

62
04:26.760 --> 04:27.630
We've got dialog,

63
04:27.640 --> 04:27.900
yes...

64
04:27.900 --> 04:33.780
but the main ones are GET and POST. And you've got a whole lot of people on the one hand wanting to endorse

65
04:33.780 --> 04:35.480
other methods like PUT and DELETE.

66
04:35.490 --> 04:39.720
And then you've got other arguments on the other hand, where the developers are just saying, just...

67
04:39.720 --> 04:41.370
treat it as a POST request, who cares! 

68
04:41.520 --> 04:44.100
And the working draft is kind of just still sitting there.

69
04:44.220 --> 04:45.560
Nothing's really been done about it.

70
04:45.780 --> 04:52.470
And perhaps the only reason why we don't have PUTs and DELETEs and other methods is that no one really

71
04:52.470 --> 04:57.930
has time to fully devote to writing a specification defining all of this.

72
04:58.290 --> 05:00.300
So there you go. I hope you find that very interesting.

73
05:00.360 --> 05:06.120
You know, a lot of people spend most of their, if not all of their coding career not understanding exactly...

74
05:06.120 --> 05:09.480
why the HTML spec does not have other methods.

75
05:09.750 --> 05:10.760
So, there you go...

76
05:10.980 --> 05:13.500
just in case you were wondering. See you in the next letter 👋.