-2

I was just having a look under the hood in the new sound cloud and noticed a few thing I hadn't heard of before. I noticed there are PUT and DELETE requests sent when liking a track etc. Now, I know that you can now use SQL directly in JavaScript so I thought they would be used to access the database but I couldn't see much information sent off so I researched it a bit. However, I couldn't find much information since I understand these requests are rarely used since its insecure and the client is not guaranteed that the procedure has been carried out.

Can anyone provide some insight into PUT and DELETE and why you would use them over the usual POST and GET requests with JSON or a PHP file?

jsalonen
  • 29,593
  • 15
  • 91
  • 109
Jacob Windsor
  • 6,750
  • 6
  • 33
  • 49

3 Answers3

3

PUT and DELETE are standard HTTP verbs as described in HTTP/1.1.

The spec describes the following use for PUT:

The PUT method requests that the enclosed entity be stored under the supplied Request-URI.

The following applies for DELETE:

The DELETE method requests that the origin server delete the resource identified by the Request-URI.

If used according to spec, you should use PUT when you want to update a resource under a given URI, and DELETE when you want to delete the resources from the given address.

The spec has also specific intentions for GET and POST, but possibly since they have been the only HTTP methods browsers have historially supported, people have started to use them in purposes that DELETE and PUT have been created in the first place.

The correct application of HTTP methods is generally referred to as RESTful programming.

Community
  • 1
  • 1
jsalonen
  • 29,593
  • 15
  • 91
  • 109
1

These methods are nothing to do with the database. They are HTTP methods. See here, or here, or any other link on Google.

Paul Fleming
  • 24,238
  • 8
  • 76
  • 113
0

PUT and DELETE are types of HTTP requests; they are not SQL database commands. In a RESTful API they are used to create a new resource or delete an existing resource.

Adam
  • 43,763
  • 16
  • 104
  • 144