HTTP protocol and common status codes

Hypertext Transfer Protocol (HTTP) is an application layer protocol hypermedia document such as HTML for transmission. It is designed for communication between the Web browser and the Web server, but it can also be used for other purposes. HTTP follow the classic client - server model, the client makes a request to open a connection, and then wait for it to receive the server response. HTTP is a stateless protocol, means that the server does not retain any data (state) between two requests.

Features of HTTP

  • HTTP protocol is built on TCP / IP protocol is an application layer protocol, the default port number is 80

  • HTTP is scalable, appearing in HTTP / 1.0 protocol extensions in HTTP headers to make it very easy.

  • HTTP is a connectionless stateless , pay attention to, the nature of HTTP is stateless, the use of Cookies can create stateful sessions.

Request packet

  Requests comprises the following elements:

  • HTTP is a method, often caused by a verb like GET, POST or a noun like OPTIONS, HEAD client to define the behavior of the action. Operation is generally the client resource acquisition (GET method) or HTML form sent form values ​​(POST method).

  • Path to the resource to be acquired, usually very significant in the context of the URL element resource, (usually in the HTTP port 80).

  • HTTP protocol version number.

  • Expression optional header headers other information to the server.

  • For some like the POST method, message body contains the resources to send, which is similar to the response message body.

Response message

  In response packet contains the following elements:

  • HTTP protocol version number.

  • A status code (status code), to request execution of the corresponding told why the success or failure, and the failure.

  • A status information, the status information of the authority of the non-code description information, may be set by the server itself.

  • The HTTP headers , similar to the request header.

  • Optionally , compared to the request message, the response message containing the resource body more commonly acquired.

Common status codes :

  • 200 OK successful client requests

  • Permanent redirection request 301 Moved Permanently

  • Temporary redirection request 302 Moved Temporarily

  • 304 Not Modified unmodified file, you can use the cached files directly.

  • 400 Bad Request Due to client requests a syntax error, it can not be understood by the server.

  • 401 Unauthorized Unauthorized request. This status code must be used with the WWW-Authenticate header field

  • 403 Forbidden server receives the request, but refused to provide services. Server will usually give reasons for not providing services in the response body

  • 404 Not Found requested resource does not exist, for example, have entered the wrong URL

  • 500 Internal Server Error server unexpected error occurred, making it impossible to complete the client's request.

  • 503 Service Unavailable The server is currently unable to handle the client's request, after a period of time, the server might return to normal.

Some of the difference between HTTP and HTTPS

  • HTTPS protocol requires the CA to request a certificate, the certificate is generally free little need to pay.

  • HTTP protocol runs on top of TCP, all the contents are transmitted in clear text, HTTPS runs over SSL / TLS, SSL / TLS runs over TCP, the contents of all transmissions are encrypted.

  • Using HTTP and HTTPS connection is completely different, with the port are not the same, the former is 80, which is 443.

  • HTTPS can effectively prevent hijacking operators to solve a big problem of anti-hijack.


Guess you like