Why does HTML form tag only contain 2 methods

Why <form>

does the HTML tag only contain two methods GET and POST? The HTTP specs have other verbs as well as PUT, DELETE, etc.

+3


source to share


3 answers


None of the other methods are expected to include data organized in such a way that HTML forms are designed to provide.



For example, DELETE is expected to delete any resource pointed to by the action. Including form data in such a request would be completely pointless.

+1


source


HTML has always allowed GET and POST to use only methods on forms. The reason for this is probably because PUT and DELETE are intended to affect the resource identified by the URI, instead of accessing a resource that simply handles the request:

The main difference between POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in the POST request identifies the resource that the attached organization will handle. This resource can be a process for accepting data, a gateway to another protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request - the user agent knows what the URI is and the server MUST NOT try to apply the request to another resource.

[...]

The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by interference (or other means) on the origin server.



It will also require the web server to handle the requests appropriately by itself, handling other aspects such as authentication and authorization.

+1


source


As on the same day no popular browser implemented anything other than POST and GET.

It seems to be too much of a hassle nowadays to get browser developers to standardize together like DELETE, PUT, PATCH, etc. will work with forms. Even if we can get browser makers to agree, it will likely be at least ten years before enough users upgrade to new enough browsers for this feature to become mainstream.

Note that there are app-to-app workarounds for this. Ruby on Rails provides an option :method

for form_tag

an assistant
that allows you to send more methods, by simply using POST with a special parameter.

0


source







All Articles