Deeply parse the HTTP protocol

Latest reply: Dec 27, 2018 07:47:22 391 5 11 2

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

HTTP USES Uniform Resource Identifiers (uris) to transmit data and make connections. A URL is a special type of URI that contains enough information to find a resource

URL, the full name of an uniformresources celocator, it is called UniformResourceLocator in Chinese, it is the address used to identify a resource on the Internet. Take the following URL as an example to introduce the components of a common URL:

http://www.aspxfans.com:8080/news/index.asp? BoardID = 5 & ID = 24618 & page = 1 # name

As can be seen from the URL above, a complete URL includes the following parts:

1. Protocol part: the protocol part of the URL is "HTTP:", which means that the web page USES the HTTP protocol. You can use a variety of protocols over the Internet, such as HTTP, FTP, and so on. In this case, the HTTP protocol is used. The "//" after "HTTP" is the delimiter

2. Domain name section: the domain name section of this URL is "www.aspxfans.com". In a URL, IP address can also be used as the domain name

3. Port section: following the domain name is the port. Use ":" as the separator between the domain name and the port. The port is not a required part of the URL, and if omitted, the default port is used

4. Virtual directory section: from the first "/" after the domain name to the last "/" until the virtual directory section. A virtual directory is also not a required part of a URL. The virtual directory in this case is "/news/"

5. Filename section: from the last "/" after the domain name to the "?" So far, is the file name part, if there is no "?" , is the file section from the last "/" after the domain name to the "#". If there is no "? And "#", so from the last "/" after the domain name to the end, is the filename part. The file name in this example is "index.asp". The filename part is not a required part of the URL, and if omitted, the default filename is used

6. Anchor part: from "#" to the end, the anchor part. The anchor part of this example is "name". The anchor part is also not a required part of a URL

7. Parameters section: from "?" The section between the start and the "#" is the parameter section, also known as the search section and the query section. The parameter section in this example is boardID=5&ID=24618&page=1. Parameters can have more than one parameter, with the & as the delimiter between the parameters.


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.



  • x
  • convention:

Tanzania163
Tanzania163 Created Dec 3, 2018 07:35:52
Good case and explanation, thanks  
4am
Created Dec 22, 2018 01:00:56 Helpful(0) Helpful(0)

Preferred application layer protocol
  • x
  • convention:

Torrent
Created Dec 22, 2018 01:20:05 Helpful(0) Helpful(0)

he 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.

thanks for sharing
  • x
  • convention:

yiyi0519
Created Dec 22, 2018 01:30:39 Helpful(0) Helpful(0)

the HTTPS is more secure than the HTTP
  • x
  • convention:

dagui
Created Dec 27, 2018 07:47:22 Helpful(0) Helpful(0)

HTTP allows the transfer of data objects of any type. The Type being transferred is marked by content-type.How do you understand this sentence?
  • x
  • convention:

Reply

Reply
You need to log in to reply to the post Login | Register

Notice Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " Privacy."
If the attachment button is not available, update the Adobe Flash Player to the latest version!
Login and enjoy all the member benefits

Login and enjoy all the member benefits

Login