What HTTP Status Codes Should Programmers be Concerned With?

前端 未结 6 1893
半阙折子戏
半阙折子戏 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:45

    Many of these are intrinsically useful with REST-style API usage. For example:

    • 200 (OK): You asked for a resource. Here it is!

    • 201 (Created): You asked me to make a new resource. I did! Here's where you can go to ask me for it next time.

    • 202 (Accepted): You asked me to do something, but it's going to take a while, so don't wait up. Here's where you can go to check up on the status.

    • 300 (Multiple Choices): You asked for something, but you weren't specific enough. Which one of these did you mean?

    • 301 (Moved Permanently): You asked for something, but it's somewhere else now. Here's where it went.

    • 302 (Found): You asked for something, but it's somewhere else for the moment. Here it is.

    • 304 (Not Modified): You asked for something before this, but it hasn't changed since the last time you asked me.

    • 400 (Bad Request): Something is wrong about what you asked me to do. Fix what you said and try again.

    • 401 (Unauthorized): I need you to identify yourself before I can finish this request. [Note: This is one of the more unfortunately named headers. It should really be titled Unauthenticated; 403 is more like Unauthorized.]

    • 403 (Forbidden): You asked for something you're not allowed to have.

    • 404 (Not Found): You asked for a resource, but there isn't one that matches your description.

    • 500 (Server Error): Something went wrong, so I can't give you what you asked for right now. Sorry about that.

    • 501 (Not Implemented): I don't support that kind of request right now.

    • 503 (Service Unavailable): I'm not able to respond to requests right now.

提交回复
热议问题