Referenced from: http://blog.csdn.net/yefan2222/article/details/6198098
Http://baike.baidu.com/view/1628025.htm?fromtitle=http&fromid=243074&type=syn
1.HTTP protocol
The basic protocol for Internate is TCP/IP (Transmission Control Protocol and Internet Protocol). The currently used ftp,http are application-layer protocols based on TCP/IP. Different protocols correspond to different applications. The HTTP protocol is the primary protocol used by Web applications.
The HTTP protocol is based on the request-response pattern, where the client sends a request to the server, the request header contains the requested method, the URI, the protocol version, and a mime-like message result that contains the request modifier, client information, and content. The server responds with a state behavior that includes the version of the message protocol, the success or error encoding plus the server information, entity meta information, and possible entity content.
2. The information exchange process for the client/server request response mechanism based on the HTTP protocol consists of the following steps:
1) Establish connection: client and server establish TCP connection
2) Send request: After a connection is opened, the client sends the request information to the appropriate port on the server and completes the request action submission.
3) Send response: The server sends a response message to the client after the client request has been processed.
4) Close the connection: both the client and server side can close the socket to end the TCP/IP conversation.
3. State management
1) Cookies
2) session
3) more Html5. Web Storage are divided into two types:
Sessionstorage
Localstorage
4. Request Method
The http/1.1 protocol defines eight methods (sometimes called "actions") to indicate the different modes of operation of the Request-uri specified resources:
OPTIONS-Returns the HTTP request methods that the server supports for a specific resource. You can also test the functionality of your server with a request to send a ' * ' to the Web server.
head-Ask the server for a response that is consistent with the GET request, except that the response body will not be returned. This method allows you to obtain meta information contained in the response message header without having to transmit the entire response content.
GET-Make a request to a specific resource. Note: The Get method should not be used in operations that produce "side effects", such as in Web apps. One of the reasons is that get can be accessed by web spiders and other casual.
POST-Submits data to the specified resource for processing requests (such as submitting a form or uploading a file). The data is included in the request body. A POST request may result in the creation of new resources and/or modification of existing resources.
PUT-Uploads its latest content to the specified resource location.
DELETE-The requesting server deletes the resource identified by Request-uri.
trace-echo the requests received by the server, primarily for testing or diagnostics.
CONNECT-The http/1.1 protocol is reserved for proxy servers that can change connections to pipelines.
PATCH-Used to apply local modifications to a resource, added to the canonical RFC5789.
HTTP Status Code list:
Status Code |
Status Code English name |
Chinese Description |
100 |
Continue |
Go on. The client should continue its request |
101 |
Switching protocols |
Switch protocols. The server switches the protocol based on the client's request. You can only switch to a more advanced protocol, for example, a new version of the protocol that switches to HTTP |
|
200 |
Ok |
The request was successful. Typically used for Get and post requests |
201 |
Created |
has been created. A new resource was successfully requested and created |
202 |
Accepted |
has been accepted. The request has been accepted, but the completion is not processed |
203 |
Non-authoritative Information |
Non-authorized information. The request was successful. But the meta information returned is not on the original server, but a copy |
204 |
No Content |
No content. The server processed successfully, but the content was not returned. Make sure the browser continues to display the current document without updating the page |
205 |
Reset Content |
Resets the content. The server processing succeeds, and the user terminal (for example: browser) should reset the document view. The browser's form fields can be cleared by this return code |
206 |
Partial Content |
Part of the content. The server successfully processed a partial GET request |
|
300 |
Multiple Choices |
Multiple options. The requested resource can include multiple locations, which can return a list of resource characteristics and addresses for use in the user terminal (for example: browser) selection |
301 |
Moved Permanently |
Move permanently. The requested resource has been permanently moved to the new URL, the return information will include the new URL, and the browser will automatically be directed to the new URL. Any future new requests should be replaced with a new URL |
302 |
Found |
Temporary move. Similar to 301. But resources are only temporarily moved. The client should continue to use the original URL |
60V |
See other |
See other addresses. Similar to 301. Viewing with Get and post requests |
304 |
Not Modified |
Not modified. The requested resource is not modified and no resources are returned when the server returns this status code. Clients typically cache accessed resources by providing a header indicating that the client wants to return only the resources modified after the specified date |
305 |
Use Proxy |
Use a proxy. The requested resource must be accessed through the proxy |
60S |
Unused |
HTTP status codes that have been discarded |
307 |
Temporary Redirect |
Temporary redirection. Similar to 302. REDIRECT with GET request |
|
400 |
Bad Request |
Client request syntax error, server does not understand |
401 |
Unauthorized |
Request for user authentication |
402 |
Payment Required |
Reserved for future use |
403 |
Forbidden |
The server understands the request from the requesting client, but refuses to execute the request |
404 |
Not Found |
The server could not find the resource (Web page) based on the client's request. With this code, the Web designer can set up a personalized page that "the resource you requested could not be found" |
50T |
Method not allowed |
The method in the client request is forbidden |
50W |
Not acceptable |
The server cannot complete the request based on the content attributes requested by the client |
50V |
Proxy Authentication Required |
The request requires the authentication of the agent, similar to 401, but the requestor should use the proxy for authorization |
408 |
Request time-out |
The server waits for a client to send a request that is too long and times out |
409 |
Conflict |
The server may return this code when it finishes a put request from the client, and the server conflicts when it processes the request |
410 |
Gone |
The resource requested by the client no longer exists. 410 is different from 404, if the resource is now permanently deleted and can use 410 code, the site designer can specify a new location for the resource through 301 code |
411 |
Length Required |
The server cannot process request information sent by the client without content-length |
412 |
Precondition Failed |
Prerequisite error for client request information |
413 |
Request Entity Too Large |
The request was rejected because the requested entity was too large to be processed by the server. To prevent successive requests from the client, the server may close the connection. If only the server is temporarily unable to process, it will contain a retry-after response message |
414 |
Request-urltoo Large |
The requested URL is too long (URLs are usually URLs) and the server cannot process |
415 |
Unsupported Media Type |
The server cannot process the media format that was included with the request |
416 |
Requested range not satisfiable |
Invalid scope for client request |
417 |
Expectation Failed |
Server failed to satisfy expect request header information |
|
500 |
Internal Server Error |
Server internal error, unable to complete request |
30w |
Not implemented |
The server does not support the requested feature and cannot complete the request |
502 |
Bad Gateway |
A server acting as a gateway or proxy that received an invalid request from the remote server |
503 |
Service unavailable |
Due to overloading or system maintenance, the server is temporarily unable to process client requests. The length of the delay can be included in the server's Retry-after header information |
504 |
Gateway time-out |
A server that acts as a gateway or proxy and does not get requests from the remote server in time |
505 |
HTTP Version not supported |
The server does not support the version of the requested HTTP protocol and cannot complete processing |
Basics of Web development: HTTP Requests