Remote upgrade Preparation: Use TCP client connections Web server implementation http download data

https://www.cnblogs.com/yangfengwu/p/11640870.html

 

First, build a root directory file

 

 

 

 

Second, use a browser to access

 

http://47.92.31.46:80/1.txt      or   http://47.92.31.46/1.txt

 

 

 

 

 

 

 

 

Third, the use of TCP clients to access file contents

  3.1, connect to the server using TCP client, IP / domain name Port number: 80

  

 

 

  3.2, send http protocol

 

  GET + space + / file path + space + HTTP / 1.1

  Host: + space + IP / Domain Name

 

  Two wrap to here

  

GET /1.txt HTTP/1.1
Host: 47.92.31.46


  

  

 

  After the above data transmission connection

  Data return

  

 

   

12 is : . 17 : 21 is the transmission data: the GET / . 1 .txt the HTTP / 1.1 
the Host: 47.92 . 31.46 

[views. 1] 
12 is : . 17 : 21 is the received data: the HTTP / 1.1  200 is the OK 
Server: openresty / 1.15 . 8.2 
a Date: Wed, 09 On Oct 2019  04 : . 17 : 20 is GMT 
the Content -Type: text / Plain 
the Content -Length: 10 
Last -Modified: Wed, 09 On Oct 2019 04:01:46 GMT
Connection: keep-alive
ETag: "5d9d5baa-a"
Accept-Ranges: bytes

1234567890

 

Guess you like

Origin www.cnblogs.com/yangfengwu/p/11641008.html