GET method: Information is stored in the URL field
HEAD: Serve's response message only returns the header
HTTP1.1 new methods:
PUT: Upload the file in the message body to the path specified by the URL
DELETE: Delete the file specified by the URL field
HTTP response message
Composition: status line + header + message body
Status code: Indicates the status of request processing
200 0K: The request is successful and the information is in the returned response message.
301 Moved Permanently: The requested object has been permanently moved
400 Bad Request: The request cannot be understood by the server
404 Not Found: The requested document is not on the server.
Cookies technology
Core function: Solve the stateless characteristics of HTTP
storage:
The browser has a cookies file (for local storage)
The database of the resource server has a cookies file (used to verify cookies)
There is a cookies field in the header of the HTTP request message (brought with it when requesting)
The HTTP response message has the word cookies in the header (bring it when responding)
Features: Saved locally, present in the header field when requesting a response
Cookies-like technologies, session and token mechanisms
Web caching/proxy server technology
basic concept
Core function: Establish a Web cache to allow customers to quickly obtain resources without accessing the resource server (provided that there are corresponding resources in the proxy)
When cache hits - proxy server = server + client
Shorten response time, reduce server pressure, reduce traffic transmission, and improve efficiency
Conditional GET method
Function: Ensure the timeliness of resources in the cache server
Implementation: When the cache is hit, the proxy server sends a GET request to the resource server with the If-Modified-Since field in the header
When the resource is up-to-date: the resource server only returns the response headers
When the resource is not the latest: the resource server returns the response header + response body
Email application
Mail Transfer Protocol—SMTP
SMTP (Simple Mail Transfer Protocol), based on TCP, port 25
Features:
Communication between mail servers
Based on TCP + long connection
Server = client + server
Email messages must consist of 7-digit ASCII codes
Without using a relay server, even if two servers span the Pacific Ocean, the two servers transmit directly
other
Three stages of transmission: handshake, transmission, shutdown
Command: ASCII text
Response: status code + statement
The message ends with CRLF.CRLF (CR=carriage return, LF=line feed)
SMTP vs. HTTP:
HTTP: Pull protocol, each object is encapsulated in an independent response message.
Respond to a text + graphic file, encapsulated in two responses
SMTP: push protocol (push), multiple objects are put into the same message
Respond to a text + graphic file, encapsulated in a message
SMTP messages are forced to use 7-bit ASCII encoding, and HTTP has no restrictions.
Both use the command/response interaction mode, and the commands and status codes are ASCII codes.
Use HTTP to interact with the browser and mail server to obtain mail, but still use SMTP to transmit mail!
DNS
basic concept
DNS (Domain Name System): Domain name service system, based on UDP, port 53
Function: Replaces IP address to facilitate memory (analogous to mobile phone address book service)
HTTP, SMTP, and FTP are all based on DNS services
Working Mechanism
Basic principle: Query layer by layer from bottom to top, and a caching mechanism can be set up (without accessing advanced DNS servers)
Hierarchical, distributed
DNS message
Message structure
P2P file distribution
P2P (peer-to-peer): point-to-point transmission
Web/Mail/DNS all adopt Cilent/Server structure, and P2P realizes equal protocol transmission.
Architecture diagram: u represents the upload speed, d represents the download speed, and F represents the file size.
C/S architecture VS P2P architecture file transfer
The file size is F, Us is the server upload speed, dmin is the minimum download speed, and N clients
C/S architecture:
NF/Us indicates the time it takes for the server to upload a total of NF-sized data to N clients.
F/dmin represents the download time of the slowest client
Take the maximum of the two
P2P architecture:
F/Us means that the server needs to upload at least one complete copy (which may be scattered among various clients)
F/dmin represents the download time of the slowest client
The last item indicates that the total file traffic is NF/total uplink speed
As the number of users increases (under certain conditions), the advantages of P2P architecture become more and more obvious.
BitTorrent - P2P protocol
Request - Scarcity Principle - Request the part with the fewest neighbors
Response - Incentive Algorithm - Fast Upload and Fast Download
HTTP streaming and CDN
HTTP streaming
Streaming video - the application plays the video as it is received and caches subsequent frames of the video.
DASH (Dynamic Adaptive Streaming over HTTP): HTTP dynamic adaptation stream
In DASH, video is encoded into different versions at different bitrates. Customers dynamically play videos with appropriate bitrates based on bandwidth conditions.
The server sends notification files indicating that there are different versions
CDN
CDN (Content Distribution Network): content distribution network
②The user sends a DNS query request to the local DNS
③The local DNS queries the authoritative server. The authoritative server detects that it is within the CDN range and does not return its own IP. Instead, it returns the DNS authoritative server for exclusive query within the CDN range.
④Local DNS sends a request to the newly obtained DNS server
⑤Local DNS returns the site server that has obtained the CDN content
⑥The user and the exclusive content distribution server send a download request