HTTP message, status code

Request message

Insert picture description here

  • Start line: defines the method, access address, protocol version, CRL carriage return and line feed
  • Header line: There are multiple lines, that is, various states of the header, followed by a blank line.
  • Entity body: usually not used, usually only used when uploading files

Response message

Insert picture description here

  • Status line: that is, the response code and protocol version
  • Header line: also various header fields, for example: cookie, time, etc.
  • Entity subject: generally not availableInsert picture description here

method method

  • GET: Get a resource from the server
  • HEAD: Only get the response header of the document from the server
  • POST: Input data to the server, usually processed by the gateway program
  • PUT: Store the body of the request in the server, such as uploading a file
  • DELETE: request to delete the specified document on the server
  • TRACE: Trace the proxy server through which the request reaches the server
  • OPTIONS: request the server to return a request to support the use of the specified resource

First explanation

Insert picture description here
Insert picture description here
General header
Date: the creation time of the message
Connection: connection status, such as keepalive, close
Via: display the intermediate node (that is, the proxy server) the message passes through
Cache-control: control the cache

Request header
Accept: Media types acceptable by the server itself (eg: text/html, application/xml...)
Accept-encoding: Receive encoding format, generally refers to compression mechanisms, such as: gzip, deflate, sdch, etc.
Accept-language: Accept The language of
Host: the requested server name and port
Referer: refers to which resource the current resource is transferred from
User-agent: client agent

Conditional request header
if-modified-since: Whether the requested resource has been modified since the specified time
if-none-match: Whether the ETag tag of the document stored in the local cache does not match the Etag of the server document;

Security request header
Authorization: send authentication information to the server, such as account and password
Cookie: the client sends a cookie to the server

Proxy request header
Proxy-Authorization: Authenticate to the proxy server

Response header
age: response duration
Server: server program software name and version; generally this item should be removed on the server side

Negotiation header
accept-ranges: the type of request range acceptable to the
server Vary: the server views other header lists

Security response header
set-cookie: set cookie to the client
WWW-Authenticate: challenge authentication form from the server to the client

Entity header
Allow: List the request methods available for this entity.
Location: Tell the client where the real entity is located.
Content-Length: the length of the body.
Content-Location: the real location of the entity;
Content-Type: the object type of the body.

status code

  • 100-101 information prompt, generally rarely appears
  • 200-206 success, indicating that all the requested data has been successfully returned
  • 300-305 redirect
  • 400-415 error, client error
  • 500-505 error, server-side error

Common types

200: Indicates that the server successfully processed the request. Return to the web page
301 that the client wants to access : The resource pointed to by the requested URL has been deleted, but the location of the header in the response message indicates the new location of the resource.
302: Similar to 301, but the temporary location of the resource is specified in the location of the header of the response message.
304: If the client sends a conditional method for access, and the content of the document has not changed, the server will respond with this status code
401: The authentication method of the account and password is required to access the resource 403: The request is forbidden 404 : The server cannot find the resource requested by the client 500: Internal error
502 of the server: The proxy server received a false response from the backend server

Guess you like

Origin blog.csdn.net/qq_44564366/article/details/104901365