Ask Your Question
0

PUT vs POST difference as a computer network and internet technology student (not web developer)

asked 2022-05-29 04:38:46 +0000

I am not a web developer or anything professional. I am just a student learning topic called HTTP protocol. In which I got confused by PUT vs POST methods. This is probably not even 1 marks stuffs in most exams (unless we are explicitly asked about HTTP methods where it can weigh upto 2.5+2.5=5 marks as the maximum marks that can be asked from this topic is 10 marks and we would be expected to write 4 of the methods).

What's that all I need to know about this? I did a huge research for learning this. Mostly I stumbled upon stackoverflow. Most online sites have copied pasted the stackoverflow answer. I haven't read the HTTP RFC as I feel

a) I am not at that caliber to read and understand RFC yet. I prefer reading books written by authors who simplify those RFCs.

b) I don't feel I should do this all for a subtopic(if my luck is bad, we could get asked HTTP methods for 10 marks in exam lol, hope i don't get jinxed).

But I have read MDN docs about them, but really speaking, they added no value to my learning. Maybe that is great for web developers but as a computer science student, that really didn't make lots of sense.

So till now I have collected this much information-:

1) PUT and POST both are same thing logically. It is just that one is used for sth and another for sth just for convention.

2)PUT write documents to server. It can create new documents in specified URL or if document already exists in that URL, it can replace its contents. Whereas POST is used to send input data to server rather than some random document data.

So the difference could be in type of data sent. One sends data to store in server only, whereas other sends data to query the server for other data.

3)PUT for update in CRUD, and POST for create in CRUD.

4) PUT-: I just want data to be created at this location. Or data to be updated if it already exists. POST-: I just want data to be sent to this location.

5)PUT displays data to be sent in URL. POST doesn't. So PUT is used in google search, google maps, whereas POST is used in forms data.

6)PUT is idempotent meaning doing PUT 1000 times will have the same result as doing PUT 1 time.

This is all I have learnt. While I know whatever I have learnt is all correct and well. I want few things from the users of this website. 1) A simple definition that can explain PUT and POST.

If possible, extra explanations to solidify my concept.

Figure for explanations of PUT and POST-:

https://i.stack.imgur.com/nbHen.png

https://i.stack.imgur.com/iNS2T.png

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-05-29 07:40:49 +0000

Jaap gravatar image

It is always a good idea to look at the RFC's, even if they may seem a bit overwhelming. In this case look at RFC 7231. As far as sending data from the client to the server these requests are similar. How the server is to handle the data is significantly different though.

For a PUT request the URI defines the resource to be manipulated. This is a restrictive definition, which results in the characteristics you already described.

For a POST request it is up to the server to determine what to do with the data in the request. Therefor it has a lot of freedom what to do with the POST request. Most notably the URI defines the API on the sever, not so much a resource to be manipulated.

After a PUT request you should be able to use a GET request to access the same resource again, this does not hold true after a POST request.

From a CS point of view you'll see that the HTTP server has an implementation to handle PUT requests itself, while POST requests are usually handed off to an external process (e.g, via FastCGI to PHP interpreter). This provides the freedom to handle the POST request as desired.

edit flag offensive delete link more

Comments

ah..thanks for the information and helpful tip.

shivajikobardan gravatar imageshivajikobardan ( 2022-05-29 13:42:05 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-05-29 04:38:46 +0000

Seen: 55 times

Last updated: May 29