HTTP (Hypertext Transfer Protocol) is an application layer communication protocol.
Introduction to HTTP Protocol Versions:
HTTP/0.9: Only accepts the GET request method, does not specify a version number in communication, and does not support request headers. Since this version does not support the POST method, clients cannot send much information to the server.
HTTP/1.0: The first version to specify a version number in communication, widely adopted to this day, especially in proxy servers.
HTTP/1.1: The current version, where persistent connections are used by default and work well with proxy servers. It also supports pipelining multiple requests simultaneously to reduce line load and improve transmission speed.
HTTP/2.0 is under development…
Differences Between HTTP/1.1 and HTTP/1.0:
1. Persistent Connection
In HTTP/1.0, each pair of request/response uses a new connection.
HTTP/1.1 supports persistent connections (by default).
2. Host Domain
HTTP/1.1 adds a Host field in the request message header; HTTP/1.0 does not have this field, as the IP address was already specified when establishing the TCP connection, and by default, one IP address corresponds to one hostname, with only one host on that IP address.
3. Bandwidth Optimization
HTTP/1.1 introduced the Range header in request messages, allowing requests for only a portion of a resource. In response messages, the Content-Range header declares the offset and length of the returned part of the object. If the server responds with the content of the requested range, the response code is 206 (Partial Content), which prevents the cache from mistakenly treating the response as a complete object. If the request message contains a large entity but it is uncertain whether the server can accept the request (e.g., due to permissions), sending a request with an entity could waste bandwidth if rejected. HTTP/1.1 added a new status code 100 (Continue). The client first sends a request with only headers; if the server rejects the request due to permissions, it responds with 401 (Unauthorized); if the server accepts the request, it responds with 100, allowing the client to continue sending the complete request with the entity. Note that HTTP/1.0 clients do not support the 100 response code.
A very effective way to save bandwidth resources is to compress the data being transmitted. Content-Encoding is an end-to-end encoding of the message, which may be the inherent format in which the resource is saved on the server (e.g., JPEG image format); the Accept-Encoding header in the request message informs the server of the encoding methods the client can decode. Transfer-Encoding is a hop-by-hop encoding, such as Chunked encoding. The TE header in the request message tells the server the transfer-coding methods that can be accepted.
4. Request Methods and Status Codes
HTTP/1.1 adds the request methods OPTIONS, PUT, DELETE, TRACE, and CONNECT.
HTTP/1.0 defined only 16 status response codes, which are not specific enough for errors or warnings. HTTP/1.1 introduced a Warning header, adding descriptions for error or warning messages.
HTTP/1.1 introduced 24 new status response codes, such as 409 (Conflict), indicating a conflict with the current state of the requested resource; 410 (Gone), indicating that a resource on the server has been permanently deleted.
5. Content Negotiation
To accommodate users of different native languages and character sets on the internet, some web resources have different language versions (e.g., Chinese version, English version). HTTP/1.0 defined the concept of content negotiation, meaning that the client can inform the server which language (or character set) representations of resources it can accept. For example, if the server cannot determine what type of resource the client needs, it will return 300 (Multiple Choices) and include a list declaring the different available versions of that resource, after which the client includes the Accept-Language and Accept-Charset headers in the request message to specify the desired version.
6. Status Codes
100-199: Informational status codes, indicating successful receipt of the request, requiring the client to continue submitting the next request to complete the entire processing.
100 (Continue) to continue sending.
200-299: Success status codes, indicating successful receipt of the request and completion of the entire processing, commonly 200 (OK) for successful receipt.
300-399: Redirection status codes, for example, the requested resource has moved to a new address, commonly 302, 307, and 304.
400-499: Client request errors, commonly 404 (Not Found), 403 (Forbidden).
500-599: Server errors, commonly 500.
Software Testing Video Link: https://ke.qq.com/course/159919#tuin=ba4122
Songqin Network: www.songqinnet.com
WeChat Official Account: Songqin Software Testing
Software Testing Communication QQ Group: 642067188
Software Automation Testing Communication QQ Group: 398140461
Software Performance Testing Communication QQ Group: 348074292