current position:Home>Understand the basic history and knowledge of HTTP

Understand the basic history and knowledge of HTTP

2022-04-29 13:33:10Crmeb mall source code

1990 Years ago

Before the 1990s , The Internet has not been invented yet , At that time, the Internet basically sent e-mail (Email1965 The invention of ) And other forms are simple and practical

1990 Years later, the world

  • Tim Berners-Lee( Hereinafter referred to as Sir Lee ) stay 1989 - 1992 Year , Invented WWW(World Wide Web)
  • It mainly includes three concepts URI, Commonly known as the website HTTP, A protocol for transferring content between two computers HTML, Hypertext , Mainly used to do page Jump URL The function of is to let you visit a page ,HTTP The function of is to let you download this page ,HTML The function of is to let you understand this page Perfect match, not tired to work
  • In addition to inventing these concepts , also : Invented the first server Invented the first browser Wrote the first web page He won the most prestigious award in the field of computer science —— Turing Award The father of the World Wide Web Tim Berners-Lee Turing award : Bonus 100 Thousands of dollars ( Click to view the award information )

URI(Uniform Resource Identifier)

Is a string used to identify the name of an Internet resource URI It is divided into URL and URN, We usually use URL As web address

  • URN( Uniform resource code ) ISBN: 9787115275790 It's just one. URN, adopt URN You can be sure of one 「 Unique 」 resources ,ISBN: 9787115275790 The corresponding resource is 《JavaScript Advanced programming ( The third edition )》 This book . You're going to introduce any library 、 The bookstore , They all know it's this book .
  • URL( Uniform resource locator ) adopt URL You can be sure of one 【 Unique 】 Address ( website )

First level domain name com Two level domain name baidu Three level domain name www

www.baidu.com

DNS

  • Enter the domain name
  • Output IP

Server + Client + HTTP

The browser is responsible for initiating the request The server 80 Port receive request The server is responsible for returning the content ( Respond to ) The browser is responsible for downloading the response content HTTP The role of is to guide the browser (Clinet) And the server (Server) How to communicate Request example 1.url -s -v -H "Frank: xxx" -- "https://www.baidu.com" The requested content is

GET / HTTP/1.1

Host: www.baidu.com

User-Agent: curl/7.54.0

Accept: */*

Frank: xxx

curl -X POST -s -v -H "Frank: xxx" -- "https://www.baidu.com" The requested content is

POST / HTTP/1.1

Host: www.baidu.com

User-Agent: curl/7.54.0

Accept: */*

Frank: xxx

Format of request

1  Verb   route   agreement / edition 

2 Key1: value1

2 Key2: value2

2 Key3: value3

2 Content-Type: application/x-www-form-urlencoded

2 Host: www.baidu.com

2 User-Agent: curl/7.54.0

3

4  Data to upload 

The request consists of at most four parts , There are at least three parts .( That is to say, the fourth part can be empty ) The third part is always a carriage return (\n) Verb has  GET POST PUT PATCH DELETE HEAD OPTIONS etc. The path here includes 「 Query parameters 」, But does not include 「 Anchor point 」( The anchor point is viewed by the browser , The server doesn't see ) If you don't write the path , So the default path is / The first 2 In section Content-Type Marked the 4 Part of the format

use Chrome Send the request

open Network Enter the URL in the address bar stay Network Click on , see request, Click on 「view source」 Click on 「view source」 Click on 「view source」 Click on 「view source」 Finally ordered ? You can see the first three parts of the request If there is a fourth part of the request , So in FormData or Payload You can see it in it

Respond to

Format of response

1  agreement / Version number   Status code   State interpretation 

2 Key1: value1

2 Key2: value2

2 Content-Length: 17931

2 Content-Type: text/html

3

4  What to download 

Status code The status code should be memorized , It's what the server says to the browser 1xx Not commonly used 2xx It means success 3xx Go away 4xx It means you are wrong 5xx Say ok , I was wrong Status code query

Status code

describe

200

The request is successful . Commonly used in GET And POST request

201

Successfully requested and created a new resource

202

Accepted . Request accepted , But not finished

301

A permanent move . The requested resource has been permanently moved to the new URI, The return information will include the new URI, Browser will be automatically directed to new URI.

302

Temporary movement . And 301 similar . But resources are only temporarily moved . The client should continue to use the original URI

303

View other addresses . And 301 similar . Use GET and POST Request to view

304

not changed . The requested resource has not been modified , When the server returns this status code , No resources will be returned .

305

Using agents . The requested resource must be accessed through a proxy

400

Syntax error in client request , Server does not understand

401

Request for user authentication

402

Retain , Future use

403

The server understands the request from the requesting client , But refused to execute the request

404

The server could not find the resource at the request of the client ( Webpage ). By this code , Website designer can set " The resource you requested could not be found " Personal page of

405

Method in client request is forbidden

500

Server internal error , Unable to complete request

501

The server does not support the requested feature , Unable to complete request

502

Server acting as gateway or proxy , An invalid request was received from the remote server

503

Due to overload or system maintenance , The server is temporarily unable to process the client's request

504

Server acting as gateway or proxy , Request not obtained from remote server in time

505

The server does not support the requested HTTP Version of protocol , Unable to complete processing

use Chrome View the response

open Network Enter url Select the first response see Response Headers, Click on 「view source」, Click on 「view source」, Click on 「view source」 You will see the first two parts of the response see Response perhaps Preview, You'll see the response number 4 part

Last

If you think this article is useful to you , Please give our open source project a little bit star:http://github.crmeb.net/u/defu Thank you for  !

copyright notice
author[Crmeb mall source code],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291041434126.html

Random recommended