Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xhr method is case-sensitive?

I find that I can use both get post put delete method in uppercase or lowercase,But I can only use patch method uppercase to make it work.

var xhr = new XMLHttpRequest();
xhr.open('PATCH',url); //works
xhr.open('patch',url); //get error net::ERR_EMPTY_RESPONSE
xhr.send();

enter image description here

like image 534
Bird Eggegg Avatar asked Jan 21 '26 08:01

Bird Eggegg


1 Answers

HTTP request methods are defined to be uppercase. Section 3.1.1 of the HTTP/1.1 RFC says

The request method is case-sensitive.

Since XMLHttpRequest simply sends the given request method to the server, the above proscription applies there as well.

Some servers may accept lowercase request methods as an application of the Robustness Principle, but for the same reason you should not send them.

like image 154
Barmar Avatar answered Jan 23 '26 23:01

Barmar