What HTTP Status Codes Should Programmers be Concerned With?

前端 未结 6 1808
半阙折子戏
半阙折子戏 2021-02-03 11:06

So, if you look at the List of HTTP Status Codes, there are probably a number of them that would be useful while programming. The server might handle some things, like protocols

6条回答
  •  既然无缘
    2021-02-03 11:39

    Quickly going through that list (of status codes), here are those I often use (I am doing PHP web-development as my job) :

    • 200 OK : almost always sent by Apache
    • 301 Moved Permanently : generally sent by me (or by Apache, when using rewrite-rules)
    • 302 Found : generally sent by me (or by Apache, when using rewrite-rules)
    • 304 Not Modified : generally sent by Apache (or a reverse proxy in front of it)
    • 401 Unauthorized : generally sent by Apache
    • 403 Forbidden : generally sent by Apache
    • 404 Not Found : sent both by Apache and me -- depending on the situations
    • 410 Gone : generally sent by me
    • 500 Internal Server Error : sent both by Apache and me ; that's the one I generally use when there's a "technical" error -- even if it should never happen ^^

    And here are those I could use (especially if doing REST) :

    • 201 Created
    • 400 Bad Request
    • 402 Payment Required
    • 405 Method Not Allowed
    • 501 Not Implemented
    • 503 Service Unavailable

提交回复
热议问题