Home  >  Article  >  类库下载  >  HTTP protocol

HTTP protocol

高洛峰
高洛峰Original
2016-10-13 16:44:321520browse

1. Overview of HTTP protocol

 1. What is HTTP? Hypertext Transfer Protocol.
 2. Describe the data standards on the client and server sides. This protocol is maintained and managed by W3C.
  Version:
  HTTP1.0: A network connection needs to be established every time a request is made
  HTTP1.1: (Mainstream) Multiple requests are made and multiple responses are obtained on one network connection. A few more heads.

 3. Clarity: The browser will automatically issue a request when it encounters the following tags

  

  
  HTTP protocol

2. The composition of the HTTP protocol

1. The request part

HTTP protocol

2. Response part

HTTP protocol

3. Detailed explanation of the request part

 1. Request line:
  GET /app1/1.html HTTP/1.1
  GET: Request method.
  Common request methods: GET (default), POST, HEAD, OPTIONS, etc.
  GET: Default
  http://localhost:8080/app1/1.html?username=abc&password=123
  The submitted data is displayed , relatively unsafe, the first line of the protocol has a length limit,    (Recommended when requesting data) POST: You can pass


  username=abc&password=123
  The submitted data is in the request body, relatively safe, length no limit.

  /app1/1.html: The requested resource address. (URI)
  URL: protocol + host: port + resource address
  http://localhost:8080/app1/1.html

  HTTP/1.1: The version of the protocol used by the client browser.

  2. Request message header: (take notes and remember commonly used headers)
   Function: transfer additional information (cryptographic instructions) to the server
   Accept: inform the server of the data types (MIME types) that the client can accept
File system: distinguishes different files by their file extensions. txt jpeg
  MIME type: large type/small type. txt--->text/plain html---->text/html js---->text/javascript (specific correspondence: Tomcatconfweb.xml)
  Accept-Encoding: Inform the server of the compression encoding that the client can accept . For example, gzip
 Accept-Language: Inform the server of the language supported by the client.
 Referer: Tell the server which page it came from.

HTTP protocol

Function: Statistics of advertising effectiveness; prevent hot links.
 Content-Type: Inform the server of the MIME type of the request body
  Default type: application/x-www-form-urlencoded (the default value of the form enctype attribute)
  Specific embodiment: username=abc&password=123
  Other types: multipart/ form-data (used when uploading files)
  If-Modified-Since: Inform the server of the resource currently being accessed and the last modification time of the file in the cache.
  User-Agent: Inform the server of the type of browser
  Content-Length: The data length of the request body
  Cookie: (*****Important) Session management related

 3. Request body:
  The data can be submitted to the server, The input field in the form must have a name attribute value
  The POST request has the text
  username=abc&password=123

IV. Detailed explanation of the response part

  1. Detailed explanation of the response part
  Response line:
   HTTP/1.1 200 OK
 HTTP / 1.1: Indicate the protocol version used on the server side
   200:Response status code
  1xx 2xx 3xx 4xx 5xx
  2xx: Processed
  4xx: Request error
  5xx: Server error
  Remember the commonly used response codes:
200: Everything Normal
   302/307: Request redirection
  304: The resource on the server has not changed
  404: The accessed address does not exist
  500: Server-side error
  OK: Response? Description

  2. Response header:
   Function: Additional information (secret command) passed from the server to the client
   Location: Inform the client of the address you are visiting.
   Implement request redirection with 302/307
  Content-Encoding: Inform the client of the compression encoding (gzip) used in the response body
  Content-Length: Inform the client of the length of the response body
  Content-Type: Inform the client of the response body The MIME type of the text. Default text/html
  Refresh: Notify the client to refresh regularly
  Content-Disposition: Notify the client to open it by downloading
   Attachment; filename=23.jpg
  Set-Cookie: (*****) Session related
Expires: -1


      Cache-Control: no-cache (1.1)
    Pragma: no-cache (1.0)
                                                                                                        ccogene in in]: no-cache (1.0)

    Use three heads together to tell the browser not to cache.



   3. Response text:

   The text content parsed by the browser is the same as right-clicking to view the source code.


🎜
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more