Skip to content

HTML forms do not support the PUT, PATCH and DELETE methods #3577

Open

Description

@ericandrewlewis

Hi! This is my first issue in this repository, I'm sorry if I'm opening this discussion in the wrong place. I searched the mailing list archives and issues for this topic but couldn't find a relevant discussion.

The spec says that the <form> method attribute assumes one of three values: get, post, and dialog.

Can we add support for the put, patch, and delete methods for this attribute?

Activity

  1. annevk commented on Mar 19, 2018

    @annevk
    Member

    Probably not as that would complicate the processing model for <form> quite significantly. In particular, the same origin policy exceptions <form> has today do not allow for these methods. Either we have to forbid them in cross-origin requests or require CORS somehow. Both of those restrictions would be a first for navigations and rather risky.

  2. js-choi commented on Mar 21, 2018

    @js-choi

    As a developer, I would love this feature. Those of us who are still interested in this sort of feature may want to make a new thread in the WICG Discourse forum and post their use cases there.

  3. annevk commented on Mar 22, 2018

    @annevk
    Member

    Just know it's been attempted several times in the past and implementers have rejected it.

  4. annevk commented on Mar 22, 2018

    @annevk
    Member

    (It even used to be part of Web Forms 2.0.)

  5. js-choi commented on Mar 22, 2018

    @js-choi

    Indeed—if I recall, Hickson said long ago that there weren’t clear use cases for them…or was that for JSON form data? Well, either way, that’s why any chance of this happening would require assembling compelling use cases for them and marshaling both coordinated community support and a reasonable specification for the vendors. A tall order, but less likely things have happened…

  6. annevk commented on Mar 22, 2018

    @annevk
    Member

    I am pretty sure that the main reason implementers have rejected it is complexity.

  7. ericandrewlewis commented on Mar 22, 2018

    @ericandrewlewis
    Author

    @annevk thanks for the context, I suspected this would have came up previously. Where would discussion from the previous attempts have taken place? They would be interesting to read.

  8. annevk commented on Mar 22, 2018

    @annevk
    Member

    https://www.w3.org/Bugs/Public/show_bug.cgi?id=10671 seems to have a lot of it, though not as much the implementer angle.

  9. annevk commented on May 7, 2020

    @annevk
    Member

    As an update, #3577 (comment) still applies. We cannot bypass the same-origin policy and enforcing CORS is theoretically possible, but would require integration of that to some extent with navigation, which is completely new ground. Maybe if something like https://wicg.github.io/cors-rfc1918/ motivated adding such complexity to navigation this would become more feasible. But until that happens this isn't worth the significant cost unfortunately.

  10. lpd-au commented on May 8, 2020

    @lpd-au

    In particular, the same origin policy exceptions <form> has today do not allow for these methods.

    Thanks for your comments @annevk. Can you point me in the direction of where these exceptions are specified? Between GET and POST, they seem to have every property of PUT and DELETE covered; request body, idempotency, navigation, etc... does it raise a fresh security concern or is this a legacy issue where the specification that defines the exceptions repeats only the HTML 4 form methods by name?

    Either we have to forbid them in cross-origin requests or require CORS somehow. Both of those restrictions would be a first for navigations and rather risky.

    To me, implementing PUT and DELETE with a same-origin policy seems like a sensible minimum viable product, which would at least allow web developers to create html clients for their own REST services. Implementer interest permitting, this could later be extended with CORS support for both PUT and DELETE methods (opt-out) and GET and POST methods (opt-in). Could you also please elaborate on why you previously considered a same-origin policy for PUT and DELETE forms to be 'risky', and whether you still believe this to be the case? How does this compare to, for example:

    1. POSTing to a cross-origin HTTPS resource with an invalid TLS certificate configuration, or
    2. GETting a resource when the network is disconnected/offline, or
    3. POSTing from a HTTPS form to a HTTP resource?
  11. annevk commented on May 8, 2020

    @annevk
    Member

    HTML defines part of it and so does https://fetch.spec.whatwg.org/. And yes, what HTML forms can do are basically the enshrined exception.

    A same-origin mode would similarly be risky (and unclear) as navigation does not have that primitive. So you'd have to define what happens if you get a cross-origin redirect and how that would be handled and such. And come to think of it, there's also a couple POST-specific code paths that would have to be generalized somehow.

  12. lpd-au commented on May 8, 2020

    @lpd-au

    HTML defines part of it and so does https://fetch.spec.whatwg.org/. And yes, what HTML forms can do are basically the enshrined exception.

    That is to say, the exception could be extended if the specification editors such as yourself thought it prudent? There is no immovable W3C charter issue, for example, or fresh security concern that does not apply to the existing methods?

    A same-origin mode would similarly be risky (and unclear) as navigation does not have that primitive. So you'd have to define what happens if you get a cross-origin redirect and how that would be handled and such. And come to think of it, there's also a couple POST-specific code paths that would have to be generalized somehow.

    I'm afraid I still don't understand. Perhaps you could define what you mean by risky, or elaborate what some of the risks are? Is there an inherent problem or insurmountable issue with having to define how redirects are handled, or generalising code previously implemented to handle POST? Is this not still significantly less complex than CORS support?

  13. 41 remaining items

  14. jlunman commented on Apr 7, 2026

    @jlunman

    But in the context of a browser form, the client has no way of knowing if it is safe to retry, wheras if the method is DELETE, then the browser knows if the request fails, it can safely make the request again. So while the operation can be done with POST, DELETE would be better.

    So you think the browser should automatically retry unsafe requests (DELETE, PUT), simply because they're supposed to be idempotent? Sounds dangerous to me.

  15. anarchodin commented on Apr 8, 2026

    @anarchodin

    So you think the browser should automatically retry unsafe requests (DELETE, PUT), simply because they're supposed to be idempotent? Sounds dangerous to me.

    How is that different from GET, which can also be incorrectly implemented in an unsafe way?

  16. jlunman commented on Apr 8, 2026

    @jlunman

    How is that different from GET, which can also be incorrectly implemented in an unsafe way?

    I mean, sure... you can shoot yourself in the foot all kinds of ways. But destructive operations are not the primary use case for GET requests. Whereas DELETE is by its very nature destructive.

    Put another way: an inexperienced or careless developer might accidentally implement some unsafe operation behind a GET request. But DELETE and PUT are unsafe by definition. And I think it would be a mistake for browsers to retry these automatically, without user confirmation.

  17. JimDabell commented on Apr 8, 2026

    @JimDabell

    Ultimately, the methods should be chosen by the origin server and communicated somehow to the client via the media type or relationship processing rules. If the choice of method doesn’t make any difference to the other components (i.e., neither client nor intermediaries gain any value by using PUT or PATCH over POST), then we should admit that it just doesn’t matter to the architectural style.

    👆 This is exactly the point.

    But it does “make a difference to the other components” because POST does not make the useful guarantees that other methods do. Take this for instance:

    So you think the browser should automatically retry unsafe requests (DELETE, PUT), simply because they're supposed to be idempotent? Sounds dangerous to me.

    Yes, they can do that with unsafe idempotent requests, and no it is not dangerous. That’s the whole point of defining them to be idempotent – there is no difference between making the request once or several times.

    A request for DELETE /foo and a hundred requests for DELETE /foo are semantically equivalent – the result is that the /foo resource is deleted no matter how many times you make the request. The same is not true for POST /foo, which is why browsers and proxies can automatically retry with DELETE but cannot automatically retry with POST. This provides the value to the client and intermediaries that Fielding was talking about – the narrower semantics make the methods more useful. It’s an example of the principle of least power in action.

    This is also not "RPC", in which the procedure to be called is tunneled via some completely opaque protocol such as SOAP. Every query and command resource has its own unique identity. And the query resources, which use GET, all benefit from caching intermediaries.

    “RPC” does not mean “tunnelling”, it means “remote procedure call”. You are telling us to stop thinking in terms of hypermedia (“stop thinking of resources as data”) and instead think in terms of RPC (“instead think of them as commands and queries”). It doesn’t matter how opaque or transparent the RPC call is in terms of the transport protocol; you are advocating RPC over HTTP instead of hypermedia.

  18. jlunman commented on Apr 8, 2026

    @jlunman

    Hypermedia has nothing to do with HTTP method semantics. It has to do with the server telling the client which state transitions are available for the current resource, rather than the client making assumptions based on convention or prior knowledge.
    That's all. The method semantics are a completely separate concern from hypermedia.

    And I don't discourage "resources as data". It's true that if you're working with an API that treats resources as data, then HTTP CRUD conventions are much more relevant - especially in the absence of hypermedia. And certainly, allowing forms to make PUT and DELETE requests would be useful in that context.

    And if that's how you want to architect your application/APIs, that's perfectly fine! You'll get zero argument from me.

    All I'm saying is that you don't have to think of resources as data. There's a different mental model that is equally valid, and aligns perfectly with the architecture of the web, and the original definition of REST.

    In a traditional server-rendered HTML application, resources represent application state (that is, what "state" your application is in), not data. And the available state transitions are expressed as hypermedia within the resource itself (links and forms). This is what the infamous unpronounceable acronym HATEOAS describes: Hypermedia as the Engine of Application State. This treats the browser not as a runtime host for a client-side JS application that calls some APIs, but as a universal client application unto itself, whose UI is entirely driven by the server. This is the architecture described in Fielding's original REST dissertation.

    There is a subtle disinction between deleting a resource, and posting a request to delete some underlying data. Neither is more correct. Just different.

  19. jlunman commented on Apr 8, 2026

    @jlunman

    Just as a thought experiment, consider the following scenario:

    You have an HTTP backend that allows you to delete things via DELETE /things/foo. And let's say this proposal goes through, and you can then write a form like this in HTML:

    <form method="delete" action="/things/foo">
        <button>Delete Foo</button>
    </form>
    

    Great! No complaints.

    But... suppose a new business requirement emerges: In order to delete a thing, the user must include a comment, explaining why they are deleting the thing. How would you implement this requirement?

    Maybe like this?

    <form method="delete" action="/things/foo">
        <label for="reason">Reason for deletion:</label>
        <textarea id="reason" name="reason" required placeholder="Explain yourself here..."></textarea>
        <button>Delete Foo</button>
    </form>
    

    But where should the "reason" field go, in the DELETE request when you submit this form?

    In the Request Body?
    That feels like the most sensible place for it. But sadly this is not broadly reliable - particularly when you don't know/control all the intermediaries.

    Per RFC-9110

    content received in a DELETE request has no generally defined semantics, cannot alter the meaning or target of the request, and might lead some implementations to reject the request and close the connection because of its potential as a request smuggling attack. [...] A client SHOULD NOT generate content in a DELETE unless it is made directly to an origin server that has previously indicated [...] will be adequately supported. An origin server SHOULD NOT rely on private agreements to receive content, since participants in HTTP communication are often unaware of intermediaries along the request chain

    In the Request Headers?
    Maybe a custom request header like x-reason: blah+blah+blah...?
    But request headers have effective size limits (which vary by client, server, and intermediaries). So if the user types a moderately long explanation, they could easily end up with a 431 Request Header Fields Too Large error.

    In the Query String?
    Of course not. That would change the URL, implying you're deleting /things/foo?reason=... rather than deleting /things/foo.

    The moment you need to convey anything remotely more complex than DELETE /things/foo, you have no choice but to embrace something like POST /things/foo/delete, which, according to some in this thread, would violate the holy purity of HTTP semantics! 🙂

    Again. I have no beef with this proposal, nor with HTTP CRUD-style APIs in general. What I'm pushing back against is the pedantic assertion that using POST for actions that may have similar semantics to other HTTP methods is inherently wrong. It's not.

  20. legowerewolf commented on Apr 8, 2026

    @legowerewolf

    Pedantically, I feel like in that case you're PUTting a tombstone, not actually deleting the resource.

  21. jlunman commented on Apr 8, 2026

    @jlunman

    Pedantically, I feel like in that case you're PUTting a tombstone, not actually deleting the resource.

    Let the bike shedding begin. 🤣

    PUTting a "tombstone" is even less semantically correct. That's like replacing a file with a new file that says it's deleted, rather than actually deleting it. It makes it even harder for intermediaries - even bespoke ones - to reason about the request, as the actual operation (delete) is now hidden entirely in the request body, masquerading as an update, and indistinguishable from other PUT requests.

    The "reason" field in my example is not a property of the deleted resource. It's a property of the operation itself. It may end up in an audit log or a notification email, or wherever. But it makes zero sense to PUT it to /things/foo. It is much more honest and logical to POST /things/foo/delete - meaning, you are posting a "request to delete some data, for this reason".

    Contorting your domain model to try to fit HTTP CRUD semantics is precisely the sort of thing that prompted Fielding's "It is okay to use POST" article in the first place.

  22. alexpetros commented on Apr 8, 2026

    @alexpetros

    In the interest of the people watching this thread to track the issue at hand, please try to keep discussion about the merits of the proposal itself. Last update on that is up here.

  23. matthewquinn commented on Apr 8, 2026

    @matthewquinn

    Jlunman's comments are about the feasibility and practicability of this solution...

  24. jlunman commented on Apr 8, 2026

    @jlunman

    Well, I did stir the pot a bit by sharing Fielding's blog post and sharing an alternate perspective. But I respect that this is not the proper forum for that debate, so - apologies.

    In regards to the proposal itself, I do have some safety concerns that I have voiced here in the past - especially the fact that browsers currently fallback to GET if the method attribute is any value other than GET or POST, and what that could mean for information leakage given the long tail of old browsers still in use. This would seem to be addressed by the proposed custommethod attribute. So <form method="post" custommethod="put"> would perform a PUT on browsers that support it, and POST on those that don't. I think it could be a bit confusing to see both method and custommethod attributes on a form, with values that seem to contradict each other, but I don't really have a better solution to offer there. (Mildly, I would prefer httpmethod over custommethod as that's a little bit more explicit, but I don't feel strongly about it, and maybe that only makes sense if the action uses the http protocol.)

    I definitely think it's worth debating whether browsers should automatically resubmit unsafe idempotent methods without user confirmation. At the very least, I'd want there to be a browser setting for that. And if they do automatically re-submit, what's the retry interval and limit?

    I'm also curious whether @mamund's idea regarding the use of ETag and Last-Modified headers to allow for conditional requests has made it into the proposal. I didn't see it at a glance, but I like it in principle.

  25. matthewquinn commented on Apr 8, 2026

    @matthewquinn

    I definitely think it's worth debating whether browsers should automatically resubmit unsafe idempotent methods without user confirmation. At the very least, I'd want there to be a browser setting for that. And if they do automatically re-submit, what's the retry interval and limit?

    If the origin is struggling with server load automatic retries could DDOS the server.

  26. alexpetros commented on Apr 8, 2026

    @alexpetros

    @jlunman I added httpmethod/custommethod as a possibility in response to your original comment in 2024, as I share those concerns. Either name would be fine, I think, and I'd definitely be open to better ideas if people have them. This proposal makes no changes to the browser's handling of unsafe, idempotent requests, so it's not on-topic for this issue. I addressed Mike's ETag proposal in this comment, and the tl;dr is that it's good idea, but not in scope for this issue.

  27. JimDabell commented on Apr 9, 2026

    @JimDabell

    I definitely think it's worth debating whether browsers should automatically resubmit unsafe idempotent methods without user confirmation.

    The entire point of including the concept of idempotency in HTTP is to enable this behaviour. It’s a deliberate design decision that doesn’t need to be re-litigated here. See RFC 9110: HTTP Semantics § 9.2.2: Idempotent Methods:

    A request method is considered "idempotent" if the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request. Of the request methods defined by this specification, PUT, DELETE, and safe request methods are idempotent.

    Idempotent methods are distinguished because the request can be repeated automatically if a communication failure occurs before the client is able to read the server's response. For example, if a client sends a PUT request and the underlying connection is closed before any response is received, then the client can establish a new connection and retry the idempotent request. It knows that repeating the request will have the same intended effect, even if the original request succeeded, though the response might differ.

    There’s no reason to include idempotency in HTTP except to enable this kind of behaviour. It’s a deliberate part of HTTP, put in there to explicitly allow automatically resubmitting unsafe requests. HTTP was designed specifically with this in mind.

  28. jlunman commented on Apr 9, 2026

    @jlunman

    @JimDabell That's fair. And I guess it really depends on the nature of the "failure". If the server responds with a 500 error, browsers do not automatically retry even a GET request. But they may retry a GET in the event of a network communication failure. And per that same spec, they should only retry once ("A client SHOULD NOT automatically retry a failed automatic retry."), so that should alleviate any DDOS concerns raised by @matthewquinn.

    Anyway, @alexpetros already stated this is not in scope for his proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions