J2ME Learning (2) - HTTP Agreement Preliminary
1 Introduction
HTTP (Hypertext Transfer Protocol), the Chinese name is a hypertext transfer protocol, working in the OSI seven-layer system, which belongs to the high-level application protocol.
The HTTP protocol is mainly used to communicate between browsers and web servers.
The HTTP protocol is transmitted using a clear text. If you need to transfer it, you can use HTTPS (Note: J2ME is temporarily not supported).
The HTTP protocol has a lot of ways to send, as follows
2, HTTP protocol version
The HTTP protocol has 3 versions, which are 0.9, 1.0, 1.0, 1.1. The latest version is 1.1, but 1.0 is generally
stand by.
3, send method
The HTTP protocol can be divided into a variety of methods according to the transmission data, where HTTP0.9 support can be divided.
GET, POST two methods, HTTP1.0 supports 7 methods, and HTTP1.1 supports more methods.
Common methods have GET and POST.
The difference between the GET method and the POST method is to transmit data, the location of the data is different. The GET method places the parameters in the request line inside the protocol. The POST method will be placed in the entity data section.
More detailed information can be referring to: http: //dev.9cbs.net/Article/10/10865.shtm
4, protocol format
The HTTP protocol is to use a clear text, and the agreement is mainly divided into three parts:
a) Request a row / response line: This section only has a line, contains three parts: requesting the method to request a resource version of the HTTP protocol version. E.g:
Get /index.html http / 1.1
Where GET is the request method, / index.html is the requested resource, and HTTP / 1.1 refers to the version of the HTTP protocol supported by the client.
b) Head information: The header information is mainly transmitted by some of the setting information of the server or the client, and there can be any plurality of "name: value", for example:
Accept-language: zh-cn
User-agent: mozilla / 4.0 (compatible; msie 5.01; windows NT 5.0)
In the HTTP protocol, the use of more than 40 header information is specified, you can also define it as needed.
At the end of the header, a blank line and the entity data portion are required to be separated.
c) Entity data: When the entity data is requested, if the parameters are stored in the POST mode, it is empty when requesting the GET. When the response is stored, the data of the HTML source code feedback is stored.