HTTP and Flask Basics - HTTP Responses

Posted CHNMSCS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HTTP and Flask Basics - HTTP Responses相关的知识,希望对你有一定的参考价值。

After the request has been received by the server and processed, the server returns an HTTP response message to the client. The response informs the client of the outcome of the requested operation.

Elements:

  • Status Code & Status Message
  • HTTP Version
  • Headers: similar to the request headers, provides information about the response and resource representation. Some common headers include:
    • Date
    • Content-Type: the media type of the body of the request
  • Body: optional data containing the requested resource.


Status Codes
As an API developer, it’s important to send the correct status code. As a developer using an API, the status codes - particularly the error codes - are important for understanding what caused and error and how to proceed.

Codes fall into five categories

  • 1XX: Informational
  • 2XX: Successful response
  • 3XX: Redirection (Something happen and there was a redirection and the back end)
  • 4XX: Client Error
  • 5XX: Server Error (The client sent a request that was fine but something happened in the back end such that the server couldn’t successfully process and needs to let the user know that.)

Common Codes

  • 100: Continue (You would see for that options request which basically says, “I got the options you have permission to process, continue sending your request.”)
  • 200: OK (For the GET request)
  • 201: Created (That is going to go with a POST request.)
  • 304: Not Modified (If a PUT or PATCH request was unsuccessful)
  • 400: Bad Request (This is one of those client errors, it means something about that request format was wrong and the server could not handle it.)
  • 401: Unauthorized (The request was formatted fine but you don’t have access to what you wanted to do or to that resource either the operation or the resource or both)
  • 404: Not Found (Whatever resource you were requesting doesn’t actually exist in the back end.)
  • 500: Internal Server Error (This one is broad category of something happened in the server while attempting to process a valid request from the client and it was not able to be completed.)

以上是关于HTTP and Flask Basics - HTTP Responses的主要内容,如果未能解决你的问题,请参考以下文章

Backup and Recovery Basics2

✿4-The Basics-Qt Quick and QML

[转]2017 frontend developers should go back and master the basics

✿4-The Basics-Qt Quick and QML

✿4-The Basics-Qt Quick and QML

P4 开发实践 — NG-SDN Tutorial — Exercise 2: Yang, OpenConfig, and gNMI basics