Directory
Java EE: First, illustrated HTTP protocol
Java EE: Second, graphic Cookie (cookies)
Java EE: Three, graphical session (sessions)
Overview
First, technical Cornerstone and Overview
Ii. in-depth understanding of technical cornerstones and workflow
Third, the detailed work process of the HTTP message
Iv. HTTP protocol Knowledge Supplement
V. Web application Framework or specification for HTTP protocol
Vi. Summary
Reference
First, technical Cornerstone and Overview
Q: What is HTTP?
A: HTTP is a standard TCPfor client and server-side requests and responses . is actually built on top of TCP.
When we open the Baidu page, it is this:
Https://www.baidu.com
More than a s, in fact, s means TLS, SSL. There is no explanation here, so the technical cornerstone of http:
What about the HTTP protocol? The HTTP protocol (hypertext Transfer Protocol), the Hypertext Transfer Protocol, is the transport protocol used by the server to transfer to the client browser. On the Web, servers and clients use the HTTP protocol for communication sessions. There is the idea of OOP that the structure of its session is a simple request/response sequence, that is, the browser makes the request and the server responds.
Ii. in-depth understanding of technical cornerstones and workflow
Since HTTP is a transport-layer-based TCP protocol, the TCP protocol is a connection-oriented , end- to-end protocol. Therefore, before using the HTTP protocol to transmit, first establish a TCP connection, which is why the TCP link process in the talk of the "three-time handshake."
On the Web, the HTTP protocol uses the TCP protocol instead of the UDP protocol because a web page must transmit a lot of data and ensure its integrity. The TCP protocol provides transport control, which organizes the data sequentially and corrects a series of functions incorrectly.
An HTTP operation is called a transaction, and its working process can be divided into four steps:
1, the client and the server need to establish a connection. (such as a hyperlink, HTTP begins.) )
2. After the connection is established, the request is sent.
3. After the server receives the request, responds to its response information.
4. The information returned by the client receiving server is displayed on the user's display by the browser, and then the client disconnects from the server.
Establishing a connection is actually based on a TCP connection. The schematic core work process (i.e. eliminating the connection process) is as follows:
Third, the detailed work process of the HTTP message
HTTP messages consist of requests from the client to the server and responses from the server to the client.
One, the request message format is as follows:
Request Line
General Information Header
Request Header
Solid Head
(Blank line)
Message body
, request the content of the message sent when I blog a post:
For a detailed description of the request message:
1. Request Line
Method field + URL + HTTP protocol version
2. General Information Head
Cache-control Header domain: Specifies the caching mechanism that requests and responses follow.
Keep-alive is its connection continues to be effective "in the following Baidu example, will be verified"
3. Request Header
Host header field, brain Repair bar
Referer header domain: Allows the client to specify the resource address of the request URL.
User-agent Header domain: request user information. "You can see the kernel information of some client browsers"
4. Message body
"p=278" in general, request parameters are required by the requesting principal.
second, the response message format is as follows:
Status line
General Information Header
Response header
Solid Head
(Blank line)
Message body
, which is what this blog responds to:
A detailed description of the response message:
1, status line
HTTP protocol version + status code + text description of status codes
"Like here, 200 means the request succeeds."
2. General Information Head
Keep-alive is its connection continues to be effective "in the following Baidu example, will be verified"
Date Header field: Time description
3. Response Head
Server header: Software information for the originating server that processed the request.
4. Solid Head
Content-type Header: Is the media type of the receiver entity. (This also indicates what your message body is.) )
(Blank line)
5. Message body
This is the HTML response page, which can be viewed in response in the tab page.
A simple request/response is complete.
Iv. HTTP protocol Knowledge Supplement
Request message Related:
Request line-Request method
Get request gets the resource identified by the Request-uri
Post appends new data to the resource identified by Request-uri
HEAD request Gets the response message header for the resource identified by Request-uri
PUT Request server stores a resource and uses Request-uri as its identity
Delete Request server deletes the resource identified by the Request-uri
TRACE requests the server to echo received request information, primarily for testing or diagnostics
CONNECT reserved for future use
Options request the performance of the query server, or query for resource-related choices and requirements
Response message Related:
Response Line-Status code
1XX: Indication information – Indicates that the request has been received and continues processing
2XX: Success – Indicates that the request has been successfully received, understood, accepted
3XX: Redirect – A further step must be made to complete the request
4XX: Client Error – Request syntax error or request not implemented
5XX: Server-side Error – Server failed to implement legitimate request
Common Status Codes
OK
The request succeeds (followed by the answer document for the Get and post requests.) )
304 Not Modified
The document was not modified as expected. The client has a buffered document and issues a conditional request (typically providing a if-modified-since header indicating that the customer only wants to update the document than the specified date). The server tells the customer that the original buffered document can continue to be used.
404 Not Found
The server was unable to find the requested page.
Internal Server Error
The request was not completed. The server encountered unpredictable conditions.
For example, 304, when the first time the browser opened Baidu,:
Refresh yourself:
The 304 above proves it.
1, 304 status code: Some pictures and JS files in the local client cache, again after the request, the cached file can be used.
2, above so the HTTP request, only a TCP connection, this is called the persistent connection .
V. Web application Framework or specification for HTTP protocol
Java EE people will know the servlet specification. Where the Web application container implements the objects in the HTTP protocol, the request and response objects. For example, there must be a description of the status code in the Javax.servlet.http.HttpServletResponse object,
As for how to use them, wait for a series of articles.
Vi. Summary
Review the full text, the HTTP protocol is actually our conversation, language is one of the protocols. So master the HTTP protocol to understand the following points are good:
1. What to communicate via HTTP protocol
2. How to communicate via HTTP protocol
Reference
1.JavaEE to understand the trivial: first, the schematic HTTP protocol
Java EE: First, illustrated HTTP protocol