Why is using a HTTP GET to update state on the server in a RESTful call incorrect?

后端 未结 5 1051
南笙
南笙 2021-01-17 20:22

OK, I know already all the reasons on paper why I should not use a HTTP GET when making a RESTful call to update the state of something on

5条回答
  •  情歌与酒
    2021-01-17 21:11

    The practical case where you will have a problem is that the HTTP GET is often retried in the event of a failure by the HTTP implementation. So you can in real life get situations where the same GET is received multiple times by the server. If your update is idempotent (which yours is), then there will be no problem, but if it's not idempotent (like adding some value to an amount for example), then you could get multiple (undesired) updates.

    HTTP POST is never retried, so you would never have this problem.

提交回复
热议问题