Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP PATCH support in browsers

I am designing REST endpoints for my application and i need to use PATCH for a few of the endpoints. Will all browsers that support HTTP/1.1 be able to support the PATCH ?

like image 544
java_geek Avatar asked Jun 17 '14 06:06

java_geek


People also ask

What is HTTP PATCH method used for?

The HTTP Patch method is used to request a set of modifications in the request entity to be applied for the resource recognized by the Request-URI. This method plays a vital role in improving interoperability and preventing errors by making partial changes in the resource.

How do I send a browser PATCH request?

To send a PATCH request to the server, you need to use the HTTP PATCH method and include the request data in the body of the HTTP message. The Content-Type request header must indicate the data type in the body. In this PATCH request example, we send JSON to the ReqBin echo endpoint to update the data on the server.

What is HTTP PATCH in Web API?

The HTTP PATCH request method applies partial modifications to a resource. PATCH is somewhat analogous to the "update" concept found in CRUD (in general, HTTP is different than CRUD, and the two should not be confused). A PATCH request is considered a set of instructions on how to modify a resource.

Is PATCH a valid HTTP method?

The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE.


1 Answers

HTTP/1.1 did not define the PATCH method.

HTTP/1.1 does leave itself open for clients and/or servers to add new methods.

RFC 5789 defined the conventions for using the PATCH method.

The method defined within a HTTP request is nothing more than a string. Browsers should allow JavaScript to use whatever HTTP method it wants in the XmlHttpRequest; see this Q&A for more info. In short, any modern browser will allow you to do this, i.e. IE9+ and Firefox/Chrome/Safari/Opera/Spartan from the last few years.

Also, don't forget the server needs to specifically handle the PATCH method too, it doesn't just magically happen.

like image 56
thecoshman Avatar answered Oct 21 '22 19:10

thecoshman