5 ms·
I haven't seen a PATCH used in any real fashion, but PUT is now a fairly standard part of most HTTP APIs.
by ominous_prime 15y ago
I haven't seen a PATCH used in any real fashion, but PUT is now a fairly standard part of most HTTP APIs.
- losvedir 15y ago> but PUT is now a fairly standard part of most HTTP APIs. Is it? I know Rails uses "put" for editing a model, but it was my understanding that it simulates this via a hidden field in the form and actually issuing a POST request. Why does it behave that way? I thought it was because many browsers don't support PUT, but maybe it's for other reasons?
- ominous_prime 15y agoI'm referring to an HTTP API (RESTful if you will). HTML forms only support GET and POST, but browsers support GET, POST, PUT, and DELETE via XMLHttpRequest. Also, access to a lot of services' APIs don't come from browsers at all.
- losvedir 15y agoThanks for the clarification. I didn't realize it was only HTML forms limited to GET and POST and not the browser as a whole.
- RyanMcGreal 15y agoPUT is not supported in the browser [1], but web APIs are mainly intended for non-browser clients to access. A client app that consumes a well-designed HTTP web API will use POST to create a resource, PUT to update a resource, and so on. [1] With the caveat that the Javascript XMLHttpRequest API does support PUT and DELETE.
- Sniffnoy 15y agoI don't understand this distinction. A client is a client; how are you to distinguish "browsers" from other clients?
- ominous_prime 15y agoThe GP here was poorly worded. It's not that browsers don't support PUT and DELETE (they do, and it's used all the time vie XMLHttpRequest), it's that HTML doesn't support those verbs for forms. You're right in that a "client is a client", and the API doesn't (or shouldn't) care.