Home > Web Front-end > HTML Tutorial > HTTP protocol

HTTP protocol

WBOY
Release: 2016-10-15 10:32:02
Original
1319 people have browsed it

1. Overview of HTTP protocol

 1. What is HTTP? Hypertext Transfer Protocol.
  2. Describes 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 issued 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

  

  
  

2. Composition of HTTP protocol

 1. Request part

  

  2. Response part

  

3. Detailed explanation of the request part

 1. Request line:
  GET /app1/1.html HTTP/1.1
  GET: request method.
  Commonly used 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, <1kb.
  (recommended when requesting data) POST: can be submitted through


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

  /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 headers: (take notes and remember commonly used headers)
  Function: transfer additional information (secret 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 that the client can accept it compression encoding. For example, gzip
 Accept-Language: Inform the server of the language supported by the client.
 Referer: Tell the server which page it came from.

  

  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) Related to session management

 3. Request text:
  For data to be submitted to the server, the input field in the form must have a name attribute value
  Only for POST requests can there be text
  username=abc&password=123

4. Detailed explanation of the response part

  1. Detailed explanation of the response part
  Response line:
   HTTP/1.1 200 OK
  HTTP/1.1: Describe the protocol version used by the server
   200: Response status code
   1xx 2xx 3xx 4xx 5xx
 2xx: Processed
4xx: The request is available Error
  5xx: Server error
  Remember the commonly used response codes:
  200: Everything is normal
  302/307: Request for redirection
  304: The resource on the server has not changed
  404: The accessed address does not exist
  50 0: server Terminal 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 to control time


     Cache-Control: no-cache (1.1)
    Pragma: no-cache (1.0)
    The three headers are used 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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template