You can send data to the server in the body of the HTTP PUT message. The type and size of data are not limited. But you must specify the data type in the Content-Type header and the data size in the Content-Length header fields. You can also send data to the server using URL parameters. In this case, you are limited to the maximum size of the URL, which is about 2000 characters (depends on the browser).
The PUT method is defined as idempotent, which means that multiple identical PUT requests should have the same effect as a single request.
The following example demonstrates sending a PUT request to the server:
And the server response:
Some notes on PUT requests:
- PUT requests are never cached
- PUT requests do not remain in the browser history
- PUT requests cannot be bookmarked
GET vs PUT
|Browser BACK button/Reload||Harmless||Data will be re-submitted (the browser should alert the user that the data are about to be re-submitted)|
|Bookmarked||Can be bookmarked||Cannot be bookmarked|
|Cached||Can be cached||Not cached|
|History||Parameters remain in browser history||Parameters are not saved in browser history|
|Restrictions on data length||Yes, when sending data, the GET method adds the data to the URL; and the length of a URL is limited (maximum URL length is 2048 characters)||No restrictions|
|Restrictions on data type||Only ASCII characters allowed||No restrictions. Binary data is also allowed|
|Security|| GET is less secure compared to PUT because data sent is part of the URL |
Never use GET when sending passwords or other sensitive information!
|Visibility||Data is visible to everyone in the URL||Data is not displayed in the URL|