Three, HTTP response

Is the HTTP message exchange of data between server and client

There are two types of messages:

  • Request - sent by the client to a server on the triggering action
  • Appropriate - response from the server

First, the configuration of the HTTP response

State 1, Line

HTTP response start line is called a status line, contains the following information:

  • Protocol version, usually HTTP / 1.1
  • Status code, indicating that the request is a success or failure. Common status code 202,404, or 302
  • Status text. A brief, purely informational, status code via text description to help people understand the HTTP message

2、Headers

Corresponding HTTP headers and any other header follow the same structure: a case-insensitive string, followed by a code number (:) and the value of a structure depends on the type of header, the entire header (including the value) appears as a single line form

3、Body

The last part of the response is a body, not all responses have body: specific response status code (e.g., 201 or 204) is not usually the body

Second, the common status codes

1 success

  • 200-ok
  • 201-created

2. Redirect

  • 300-Mutiple Choice
  • 301-Moved Permanently
  • 302-Found

3, client error

400-Bad Request

401-Unauthorized

402-Payment Required

403-Forbidden

404-Not Found

4, client error

 500-Internal Server Error

501-Not Implemented

502-Bad Gateway

 

Guess you like

Origin www.cnblogs.com/xinxin1994/p/11258526.html