Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can HTTP PUT request have application/x-www-form-urlencoded as the Content-Type?

Is it valid to send form data in an HTTP PUT request? If you could point me to a spec then that would be great.

I have gone through the HTTP 1.1 spec. But I did not find whether PUT requests can have form data or not.

I am using Java for creating and accessing RESTful webservices. POST supports application/x-www-form-urlencoded as the Content-Type.

From the specification, I understand that POST is for creating a new resource (a subresource to the resource identified by the request URI) and PUT is for create or update a resource.

But my doubt is whether PUT method also can have form data in it? I trying to find out whether it is fine according to the spec. And I can't find anything about this in the HTTP 1.1 spec.

like image 791
Paul Nibin Avatar asked Jun 10 '11 12:06

Paul Nibin


People also ask

What is content type application x www Urlencoded?

The application/x-www-form-urlencoded content type describes form data that is sent in a single block in the HTTP message body. Unlike the query part of the URL in a GET request, the length of the data is unrestricted.

How do I send a POST request with X-www-form-Urlencoded body?

String urlParameters = cafedra_name+ data_to_send; URL url; HttpURLConnection connection = null; try { //Create connection url = new URL(targetURL); connection = (HttpURLConnection)url. openConnection(); connection. setRequestMethod("POST"); connection.

How do you send data with application X-www-form-Urlencoded?

To use it, we need to select the x-www-form-urlencoded tab in the body of their request. We need to enter the key-value pairs for sending the request body to the server, and Postman will encode the desired data before sending it. Postman encodes both the key and the value.

Is X-www-form-Urlencoded secure?

Security considerations: In isolation, an application/x-www-form-urlencoded payload poses no security risks. However, as this type is usually used as part of a form submission, all the risks that apply to HTML forms need to be considered in the context of this type.


1 Answers

Yes you can use application/x-www-form-urlencoded with PUT. The HTTP spec does not limit what methods can be used with what media types.

The currently in-progress Httpbis spec has a significantly expanded discussion of PUT https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p2-semantics-14#page-18

like image 142
Darrel Miller Avatar answered Oct 20 '22 00:10

Darrel Miller