I. Web and Network Fundamentals
TCP/IP Tiered management
Application Layer--Transport layer--Network layer--Link layer
TCP/IP Communication transport Stream
To browse the http://www.xxx.com/aaa/page, the client (browser) requests the DNS service, obtains the IP address corresponding to the domain name, generates the HTTP request message, the TCP divides the request message into several segments, relies on the IP protocol, searches the other's address, jumps one side to transmit, TCP will receive the message segment reorganization into the original order, the Web server relies on the HTTP protocol, the content of the request processing, the request processing results also with the TCP/IP protocol to the user callback.
URL format
Protocol Scheme name://Login information @ server address: Server port number/file path with hierarchy? query string # Fragment identifier
Http://user:[email Protected]:80/dir/index.htm?uid=1#ch1
Second, the HTTP protocol
The HTTP protocol is used for communication between the client and server and is a stateless protocol.
The client makes the request and the server-side response should be requested and returned.
HTTP method:
| GET |
Get Resources |
| POST |
Transport entity Body |
| PUT |
Transferring files |
| HEAD |
Get message header |
| DELETE |
deleting files |
| OPTIONS |
Ask for supported methods |
| TRACE |
Trace Path |
| CONNECT |
Require tunneling protocol to connect proxies |
Persistent connections
The TCP connection state is maintained as long as no disconnection is made at either end.
Pipeline
You can send the next request directly without waiting for a response.
Cookies
Cookie technology controls the state of the client by writing cookie information in the request and response messages.
HTTP information in HTTP messages
HTTP messages
The HTTP protocol interacts with information that is called an HTTP message. The request-side (client) message is called the request message, and the response (server-side) message is called the response message.
The HTTP message is roughly divided into two parts: the header of the message and the main body of the message, separated by the empty line (CR+LF). Usually, there is no need to have a message body.
The first part of the request message is the request header field, the General header field, and the Entity header field;
The first part of the response message is the response header field, the General header field, and the Entity header field.
The header content of the request message and the response message consists of the following elements:
- Request Line
- Status line
- Header field
- Other (cookies, etc.)
Encoding improves transfer efficiency
The difference between the message body and the entity body
A message (message) is the basic unit of HTTP communication, consisting of a 8-bit byte stream (octet sequence, where Octet is 8 bits), transmitted over HTTP traffic.
Entities (entity) are transmitted as payload data (supplements) That request requests or responses, and their contents consist of the entity header and the entity body.
The body of an HTTP message is used to transfer the entity body of the request or response.
Usually, the message body is equal to the entity body, and the content of the entity body changes when it is encoded in the transmission, which causes it to differ from the message body.
HTTP protocol Learning Notes