HTTP is an object-oriented protocol belonging to the application layer, which is suitable for distributed hypermedia information system due to its simple and fast way. It was put forward in 1990, after several years of use and development, has been constantly improved and expanded. Currently, the sixth version of HTTP/1.0 is used in the WWW, normalization of HTTP/1.1 is under way, and Suggestions for HTTP -ng (Next Generation of HTTP) have been made.
The HTTP protocol works on a client-server architecture. The browser, as an HTTP client, sends all requests through the URL to the HTTP server, the WEB server. The Web server sends a response message to the client based on the request it receives.
http://upload-images.jianshu.io/upload_images/2964446-5a35e17f298a48e1.jpg?imageMogr2/auto-orient/strip%7CimageView2/2
The main features
1. Simple and fast: when a client requests a service from the server, it only needs to send the request method and path. Request methods commonly used are GET, HEAD, POST. Each method specifies a different type of client to server contact. Because the HTTP protocol is simple, the application size of the HTTP server is small, so the communication speed is very fast.
2. Flexibility: HTTP allows the transfer of data objects of any type. The Type being transferred is marked by content-type.
3. Connectionless: connectionless means that only one request per connection can be processed. The server disconnects after processing the client's request and receiving a response from the client. This method can save transmission time.
Stateless: the HTTP protocol is stateless. Stateless means that the protocol has no memory for transaction processing. The lack of state means that if the previous information is needed for subsequent processing, it must be retransmitted, which can result in an increase in the amount of data transferred per connection. On the other hand, the server responds faster when the previous information is not needed.
5. Support B/S and C/S modes.
HTTP with URL
The difference between uris and urls
A URI is a uniform resource identifier, a uniform resource identifier that uniquely identifies a resource.
Every resource available on the Web such as HTML documents, images, video fragments, programs, and so on is located by a URI
Uris generally consist of three parts:
(1) naming mechanism for accessing resources
(2) host name of the storage resources
The name of the resource itself, represented by the path, emphasizes on the resource.
A URL is a uniform resource locator, a specific URI, that is, a URL can be used to identify a resource and specify how to locate the resource.
URL is a string used on the Internet to describe information resources, mainly used in a variety of WWW client and server programs, especially the famous Mosaic.
Using urls allows you to describe a variety of information resources in a uniform format, including files, server addresses, directories, and so on. URL generally consists of three parts:
Agreement (or service mode)
(2) host IP address (sometimes including port number) containing the resource
(3) the specific address of the host resources. Such as directories and file names
URN, uniform resource name, refers to identifying a resource by name, such as mailto:java-net@java.sun.com.
Uris are abstract, high-level concepts that define uniform resource identifiers, while urls and urns are concrete resource identifiers. Urls and urns are both uris. In general, every URL is a URI, but not every URI is a URL. This is because the URI also includes a subclass, the uniform resource name (URN), which names the resource but does not specify how to locate it. The mailto, news, and isbn uris above are examples of urns.
In Java uris, a URI instance can represent either absolute or relative, as long as it conforms to the URI's syntax rules. The URL class, on the other hand, not only conforms to the semantics, but also contains information about locating the resource, so it cannot be relative.
In the Java class library, the URI class does not contain any methods to access resources; its only purpose is resolution.
Instead, the URL class can open a stream to a resource.