HTTP protocol (i)

Source: Internet
Author: User

HTTP protocolAgreement: is a rule or regulationTCP/IP protocol:rules the communication format of TCP client and TCP server data
1. What are the Knowledge Points: HTTP protocol 2. What is the knowledge point: Specifies the data communication format between the browser and the server (TCP server) 3. Request Protocol Format < client (browser) send data to server >get/ index.html http/1.1 GET:     /index.html: Address    http/1.1: Protocol version 4. Response < server send data to client >

  

"The tcp-server sends data after receiving a client request"
#响应的格式
#1. The response header #2. Blank line #3. Response Body # 1. Response header "http1.1p version", OK: This is the status Header = "http/1.1 OK \ r \ n " #200这个是状态 Header + =" content-type:text/html;charset=utf-8 \ r \ n "#解析中文 header + =" content-length:5\r\n "#告诉浏览器显示多少 Characters # 2. Body of response body = "python10" content = header + "\ r \ n" + Body # Return data displayed on the page client.send (Content.encode ("UT F-8 ")) Note: If there is a return picture data, you need to return two times, first return the text encoding, and then return the binary picture data      

  

Browser and server in HTTP
1. They use TCP sockets to implement the

 

HTTP process Response Header format
http/1.1 status \ r \ n
Format of the response
Response header http/1.1 \r\ncontent-type:text/html;charset = utf-8;\r\n #显示中文Content-length:10749 Display the length of the content blank line \r\ N Response Body (the contents of the returned data)
function of the request header
Tell the server we're requesting an address.
Data.splitlines () #GET/http/1.1: Response Header original Format Re.match (R ' [^/]+ (/[^]*) ', heads_01)#用正则的group得到地址file_name = Match.group (1)
The role of response
Control the display of the browser
State
the success of the 404 Not Found page does not exist 302 found jump 304 No permissions 500 server hangs

  

HTTP protocol (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.