Home >php教程 >PHP开发 >Network transfer protocol (http protocol)

Network transfer protocol (http protocol)

高洛峰
高洛峰Original
2016-12-06 14:02:591613browse

Overview: Refers to the constraints and specifications for communication between the server and the client. The data interaction between the client and the server is not messy and needs to follow (based on) certain specifications.

Common protocols:

a) HTTP、HTTPS 超文本传输协议
 
b) FTP 文件传输协议
 
c) SMTP 简单邮件传输协议

This article mainly introduces the http hypertext transfer protocol.

1. HTTP protocol

is the Hypertext Transfer Protocol. The website is based on the HTTP protocol. For example, the images, CSS, JS, etc. of the website are all transmitted based on the HTTP protocol. The HTTP protocol is constrained and standardized by the request (Request) from the client to the server and the response (Response) from the server to the client. Commonly used request methods are: GET, POST, PUT, DELETE. 2. Request -Request message:

a) The request is initiated by the client, and its standard format is: request line, request header, and request body. For example:

b) Request message line: composed of request method, request URL and protocol version

c) Request message header

Host:localhost请求的主机
Cache-Control:max-age=0控制缓存(no-cache| no-store)
Accept:*/* 接受的文档MIME类型
User-Agent:向访问网站提供你所使用的浏览器类型、操作系统及版本、CPU 类型、浏览器渲染引擎、浏览器语言、浏览器插件等信息的标识. 浏览器UA 字串的标准格式为: 浏览器标识 (操作系统标识; 加密等级标识; 浏览器语言) 渲染引擎标识 版本信息
Referer:从哪个URL跳转过来的
Accept-Encoding:可接受的压缩格式
Network transfer protocol (http protocol)

d) Request message body: that is passed to the server Data

Note: When submitting the form in the form of post, Content-Type: application/x-www-form-urlencoded will be set in the request header, but this setting is not required when requesting in the form of get

3. Response -Response message:

a) The response is sent by the server, and its standard format is: status line, response header, response body

b) Response header:

Date:响应时间
Server:服务器信息
Content-Length:响应主体长度
Content-Type:响应资源的MIME类型
Network transfer protocol (http protocol)

c) Response body: that is Content returned by the server to the client

d) Status code:

Common status codes are: 200---The server successfully returned the web page, 304---The document has not been modified, 403---No permission, 404 ---The requested web page does not exist, 500---server error, 503---service unavailable

Explanation: The client and server transmit data in byte form, which can be understood as text Form transmission, then the browser needs to know clearly how to parse these text-form data. MIME clearly tells the browser how to process itNetwork transfer protocol (http protocol)

There are many knowledge points about the http protocol. This article only introduces its transmission. Approximate process. Learning and understanding its components is to better understand ajax.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn