A brief introduction to the HTTP protocol
The HTTP protocol is a hypertext transfer protocol, which is a communication protocol based on TCP/IP for data transmission
Features:
1. Simple and fast , when the client initiates a request to the server, it only needs to transmit the request method and path. Commonly used request methods include POST, GET, etc. Each method specifies a different type of contact between the client and the server. Because the HTTP protocol is simple, the communication speed is fast
2. Flexible: any type of data object can be transmitted. The transmission type is marked by Content-Type
3. No connection: Limit each connection to only process one request. After the server processes the client's request, it will disconnect after receiving the client's response
4. Stateless: HTTP is a stateless protocol. Stateless means that the protocol has no memory ability for transaction processing. The lack of status means that if the previous information is needed for subsequent processing, it must be retransmitted, which may increase the amount of data transmitted per connection. On the other hand, when the server does not need other information, its response will be very fast
5. Supports B/S and C/S modes
URL
URL is a uniform resource identifier used by HTTP to transmit data and establish connections. URL is a special type of URI, the full name is UniformResourceLocator, and the Chinese name is Uniform Resource Locator. The URL contains the following parts:
For example: https://baike.baidu.com:8080/item/url/110640 ?fr=aladdin
1. Protocol/mode part: It tells the browser how to handle the file to be opened. The most commonly used mode is the Hypertext Transfer Protocol (HTTP), which is used to access the Internet. Other protocols are as follows:
http——Hypertext Transfer Protocol resources
https - Hypertext Transfer Protocol delivered using Secure Sockets Layer
ftp——File Transfer Protocol
mailto——email address
ldap——Lightweight Directory Access Protocol Search
file - a file shared on a local computer or online
News——Usenet News Group
gopher——Gopher protocol
telnet——Telnet protocol
In the above example, the protocol part is https
2. Domain name part: The above domain name is: baike.baidu.com
3. Port part: What follows the domain name is is the port number. Use: to separate the port from the domain name. The port is not a necessary part of a URL. If the port number is omitted, the default port will be used
4. The file name part: /item/url/110640
5 . Parameter part: fr=aladdin, that is,
Request
after the question mark. The HTTP request message Request mainly consists of the following parts:
* Request line: Request method | URL | Protocol version
* Request header: The request header contains a lot of useful information about the client environment and the request body
* Request body: There is a blank line between the request header and the request body. This The line is very important, it indicates that the request header has ended, and what follows is the request body. The request body can contain query string information submitted by the customer
Response
HTTP response message Response consists of the following parts:
* Status line: Protocol version | Status code | Status Message
* Response header: Date, Content-Type, etc.
* Response text: Server-side return data
Status code
The status code consists of three digits, the first Numbers define the category of the response
* 1xx: Indication message, indicating that the request has been received, continue processing
* 2xx: Success, indicating that the request has been successfully received
* 3xx: Redirect, indicating that the request will be made at night Further operations are required
* 4xx: Client error, indicating that the request has a syntax error or cannot be implemented
* 5xx: Server error, indicating that the server failed to implement a legal request
Common status Code:
200 - ok - 请求成功400 - Bad Request - 客户端请求有语法错误,不能被服务器理解401 - Unauthorized - 请求未经授权403 - Forbidden - 服务器收到请求,但是拒绝提供服务404 - Not Found - 请求资源不存在500 - Internal Server Error - 内部服务器错误503 - Server Unavaliable - 服务器不可用
Request method
HTTP 1.0 定义了三种请求方法 :GET、POST、HEAD HTTP 1.1 新增了五种请求方法 :OPTIONS、PUT、DELETE、TRACE、CONNECT
GET - 请求指定的页面信息,并返回实体主体 HEAD - 类似于GET请求,但是返回的只有报头 POST - 向指定的资源提交数据进行处理请求 PUT - 从客户端向服务器传送的数据取代指定文件的内容DELETE - 请求服务器删除指定的页面 CONNECT - HTTP/1.1协议中预留给能够将连接改为管道方式的代理服务器。OPTIONS - 允许客户端查看服务器性能 TRACE - 回显服务器收到的请求,主要用于测试或诊断。
The difference between GET and POST
Data submission: GET request data will be placed after the URL, using & number to connect, but the POST request data will be placed in the HTTP packet
Transmission data size: Since general browsers have restrictions on the length of the URL, GET is used to request the data There will be a size limit, but POST puts the data in the package, that is, there is no size limit
Security: GET submits the data in the URL and can be cached to return the data
Note:
1. The HTTP protocol does not limit the size of transmitted data, and the HTTP protocol specification does not limit the length of the URL.
2. HTTP’s GET, POST, and SOAP protocols all run on http
(1) GET: The request parameters are appended to the URL as a sequence of key/value pairs (query string) The length of the
query string is limited by web browsers and web servers (such as IE supports up to 2048 characters), which is not suitable for transmitting large data sets. At the same time, it is very unsafe
(2) POST: The request parameters are transmitted in a different part of the http header (named entity body). This part is used to transmit form information, so Content-type must be set to: application/x-www- form-urlencoded. Post is designed to support user fields on web forms, and its parameters are also transmitted as key/value pairs.
But: it does not support complex data types because post does not define the semantics and rules for transmitting data structures.
(3) SOAP: It is a special version of http post, following a special xml message format
Content-type is set to: text/xml Any data can be xmlized.
The HTTP protocol defines many methods of interacting with the server, the most basic of which are GET, POST, PUT, and DELETE. A URL address is used to describe a resource on the network, and in HTTP GET, POST, PUT, and DELETE correspond to the four operations of checking, modifying, adding, and deleting this resource. Our most common ones are GET and POST. GET is generally used to obtain/query resource information, while POST is generally used to update resource information.
The above is the detailed content of What is HTTP protocol. For more information, please follow other related articles on the PHP Chinese website!

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.