What is? url ?

url = agreement + domain name + Resource path such as : https://www.baidu.com/index.html

  • http : Hypertext transfer protocol
  • https: Secure socket protocol

HTTP How it works

 visit https://mirrors.aliyun.com/centos-vault/readme.txt What happened when ?
1、 Browser parsing url, Yes url To resolve the domain name corresponding to IP
2、 Give domain name to DNS The server , inquiry dns The domain name of the server corresponds to IP What is it?
3、DNS return IP To the browser
4、 Browser and DNS Back to IP Of 80 Port to proceed tcp Connect
5、 Request the centos-vault/readme.txt
6、 The server response returns a status code , The browser is disconnected tcp Connect
7、 If the status code is 2xx Or is it 3xx, You can load the page 

Request analysis

Page information

#  essential information
Request URL: https://www.baidu.com/   #  Requested host
Request Method: GET # http Request method
Status Code: 200 OK #  Status code returned
Remote Address: #  Target host ip And port
Referrer Policy: no-referrer-when-downgrade
#  Response head
Bdpagetype: 1
Bdqid: 0xbb77515a0073bd0f
Cache-Control: private
Connection: keep-alive #  Establish long connection
Content-Encoding: gzip
Content-Type: text/html;charset=utf-8 #  Parsing methods and character sets
Date: Wed, 13 May 2020 02:23:21 GMT #  date
Expires: Wed, 13 May 2020 02:22:25 GMT
Server: BWS/1.1 # web Name of the server
Set-Cookie: BDSVRTM=0; path=/
Set-Cookie: BD_HOME=1; path=/
Set-Cookie: H_PS_PSSID=1438_21100_31595_31605_31270_31463_31228_30824_31163; path=/; domain=.baidu.com
Strict-Transport-Security: max-age=172800
Traceid: 1589336601022180301813508355054317583631
Transfer-Encoding: chunked
X-Ua-Compatible: IE=Edge,chrome=1
#  Request header
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3      #  The type of resource requested
Accept-Encoding: gzip, deflate, br #  Resource type compression
Accept-Language: zh-CN,zh;q=0.9 #  Resource type language
Cache-Control: max-age=0 #  Cache control , Server side cache
Connection: keep-alive #  A long connection
Cookie: BIDUPSID=C660B517FF8D703361BEF27A8E0B4A86; PSTM=1589100937; BAIDUID=C660B517FF8D7033A98FCF75B8449AC5:FG=1; BD_UPN=12314753; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_PSSID=1438_21100_31595_31605_31270_31463_31228_30824_31163; delPer=0; BD_CK_SAM=1; PSINO=6; H_PS_645EC=94f7XUqf2UNuFyrpWJocENb5EtAFjG61sQS1yaq%2B9tPHYmQPOTzqO5NtnNU; COOKIE_SESSION=83388_0_8_5_1_8_1_1_8_2_0_0_1589201145_0_0_0_1589201330_0_1589335040%7C9%230_0_1589335040%7C1; __yjsv5_shitong=1.0_7_9449884d52ca169ba37dc788ecf839422ab2_300_1589336389184_106.84.9.86_0cf955f8; yjs_js_security_passport=057098de95624ead2bac92e4c7abd3e8b8e85870_1589336389_js; BD_HOME=1
Host: www.baidu.com #  Host to access
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1 #  Client priority encryption
#  Browser and operating system identification when accessing
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36

HTTP Request method

Method (Method) meaning
GET Request to read a Web page
POST Attach a name ( Such as Web page )
DELETE Delete Web page
CONNECT For proxy servers
HEAD Request to read a Web The head of the page
PUT Request to store a Web page
TRACE Used for testing , Request the server to send the recycled request
OPTION Query specific options

Return status code

Status code meaning
200 success
301 Permanent redirection ( Jump ) If the local cache is not cleared , You can always visit , Even if the server is down .
302 Temporary redirection ( Jump ) You can't see the web page when the server is disconnected ,http Will automatically jump to https.
304 Local cache , Open the web page once , When you refresh again , Will use local caching
307 Internal redirection ( Jump )
400 Client error
401 Authentication failed
403 Home page not found , Insufficient authority ; The site directory has no content , Or lack of authority
404 Page not found
405 Request method not allowed
500 internal error , such as : The database was shut down
502 Back end host not found bad gateway
503 Server overload , Server request limit , By ddos*** You can go back like this .
504 Back end host timeout

2xx and 3xx Normal access

4xx All are nginx The error of

5xx Back end error (nginx The service connected later reported an error :mysql、php、tomcat、redis)

Normal access to the web page when the basic information inside the return of the status code :

Using local cache to load web pages

When accessing a nonexistent resource

Without a default site

When you fail to enter your user name and password on your home page


HTTP Referer yes header Part of , When the browser to web The server When the request is sent , Usually with Referer, Tell the server which page is linked from , The server can therefore obtain some information for processing .

HTTP Request process

1. Enter domain name with  ->  Browser jump  ->  Browser cache  -> Hosts file  -> DNS analysis
2. Initiated by the browser to the server TCP Connect .
3. Client initiated http request :
    1) What is the method of request :     GET obtain
    2) Requested Host The main engine is :     www.baidu.com
    3) What is the requested resource :     /index.html
    4) What is the end port of the request :     Default http yes 80 https yes 443
    5) What are the parameters carried by the request :    attribute ( Request type 、 Compress 、 authentication 、 Browser information 、 wait )
    6) Request the last blank line
4. The content of the server response is
    1) Server response uses WEB Service Software
    2) Server response request file type
    3) Whether the file requested by the server is compressed or not
    4) Whether the host that the server responds to the request makes a long connection
5. The client initiates... From the server TCP To break off