Why do we need anything more than HTTP GET, PUT, POST?

后端 未结 14 762
-上瘾入骨i
-上瘾入骨i 2021-02-04 10:09

What is the practical benefit of using HTTP GET, PUT, DELETE, POST, HEAD? Why not focus on their behavioral benefits (safety and idempotency), forgetting their names, and use GE

14条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 10:38

    HEAD is really useful for determining what a given server's clock is set to (accurate to within the 1 second or the network round-trip time, whichever is greater). It's also great for getting Futurama quotes from Slashdot:

    ~$ curl -I slashdot.org
    HTTP/1.1 200 OK
    Date: Wed, 29 Oct 2008 05:35:13 GMT
    Server: Apache/1.3.41 (Unix) mod_perl/1.31-rc4
    SLASH_LOG_DATA: shtml
    X-Powered-By: Slash 2.005001227
    X-Fry: That's a chick show. I prefer programs of the genre: World's Blankiest Blank.
    Cache-Control: private
    Pragma: private
    Connection: close
    Content-Type: text/html; charset=iso-8859-1

    For cURL, -I is the option for performing a HEAD request. To get the current date and time of a given server, just do

    curl -I $server | grep ^Date

提交回复
热议问题