When should I use GET or POST method? What's the difference between them?

后端 未结 14 1735
-上瘾入骨i
-上瘾入骨i 2020-11-21 06:44

What\'s the difference when using GET or POST method? Which one is more secure? What are (dis)advantages of each of them?

(similar question

14条回答
  •  不思量自难忘°
    2020-11-21 07:31

    There are two common "security" implications to using GET. Since data appears in the URL string its possible someone looking over your shoulder at Address Bar/URL may be able to view something they should not be privy to such as a session cookie that could potentially be used to hijack your session. Keep in mind everyone has camera phones.

    The other security implication of GET has to do with GET variables being logged to most web servers access log as part of the requesting URL. Depending on the situation, regulatory climate and general sensitivity of the data this can potentially raise concerns.

    Some clients/firewalls/IDS systems may frown upon GET requests containing an excessive amount of data and may therefore provide unreliable results.

    POST supports advanced functionality such as support for multi-part binary input used for file uploads to web servers.

    POST requires a content-length header which may increase the complexity of an application specific client implementation as the size of data submitted must be known in advance preventing a client request from being formed in an exclusively single-pass incremental mode. Perhaps a minor issue for those choosing to abuse HTTP by using it as an RPC (Remote Procedure Call) transport.

    Others have already done a good job in covering the semantic differences and the "when" part of this question.

提交回复
热议问题