HTTP: The protocol that every web developer must know-basic

Source: Internet
Author: User

http://blog.csdn.net/sql_wtx/article/details/8894447

The original is http://net.tutsplus.com/tutorials/tools-and-tips/http-the-protocol-every-web-developer-must-know-part-1/, The purpose of this article is to understand the HTTP protocol more deeply. Now that the web technology is changing, it is only through the understanding of its protocols that we can acquire these new technologies faster and more firmly. Because the article is very long, I will be divided into several blog to translate, the article also add my personal understanding, if there is anything wrong place, welcome point, Thank you!

The translation is as follows:

The HTTP full name is the Hypertext Transfer Protocol (hypertext Transfer Protocol). It is a stateless, distributed system of communication between the application layer protocol, is the basis of modern web. As a web developer, we have to be very familiar with this kind of protocol.

Let's review this powerful protocol through a web development lens. We will use two parts to solve this problem. In the first entry, we talk about the basics and outlines of the various requests and responses. In the background article, we will review the special points of HTTP, as well as caching, connection processing and validation.

HTTP Basics

HTTP allows a variety of hosts and clients to connect, and supports a hybrid network architecture. This makes HTTP a stateless protocol. Communication typically occurs via TCP/IP, but any trusted port can be used. General TCP/IP ports are 80, but other ports can be used as well.

Through a pair of requests and replies, the host and client have communicated. The client sends an HTTP request message that the server returns through an HTTP reply message. We'll look at a couple of basic messages in the next section.

The current version of the agreement is http/1.1, which adds some new features to the 1.0 release base. In my opinion, the most useful is persistent connections (long connection), chunked transfer-coding (chunked transfer encoding) and fine-grainedcaching headers (fine-grained cache header). In the back, We will understand this knowledge.

URLs

The core of web communication is the request message, which is sent via URLs. I'm sure you're familiar with the URLs, but not fully mastered. Here is the structure of the URLs:

This protocol is usually HTTP, but a secure connection is HTTPS. The default port is 80, which can be customized as well. The resource Path (resource path) is the local path on the server.

Action (Verbs)

URLs are the only traffic signs for the host, but they need to be performed on the server via HTTP actions. Of course, these operations are the client wants the service side to execute.

The request action is as follows:

    • Get: Gets the resource that already exists, and the URLs contain the resource information that all the services need to return.
    • POST: Create a new resource. Post requests often come to bring valid data to new resources.
    • PUT: Updates A resource that already exists. The put request contains updated data for the resource.
    • Delete: Deletes a resource that already exists.

The above actions are the most common, and most tools and frameworks show these request actions. Put and delete are sometimes considered special versions of Post, and it is possible for developers to include operational data in Post requests: Create,upadte and delete, replacing put and delete with post.

Translator Note: I used to basically only post and get, add an action field in post to represent new, modify, delete. But behind the touch of the restful architecture, found that HTTP 4 operations get, post, put, delete is corresponding to our often encountered the increase, delete, change, check function. The understanding of the HTTP protocol can help us expand other knowledge, such as restful, Ajax, long connection, and so on, is actually the application of the HTTP protocol, not something new.

There are several HTTP actions that are rarely used:

    • Head: With head request, the server returns only the response header, not the requested document, typically used in search engines. Or the time stamp to determine if the resource has been modified.
    • TRACE: Used to diagnose the target, through the header field to obtain the gateway and proxy IP and DNS.
    • OPTIONS: The ability for the client to view the server.

HTTP: The protocol that every web developer must know-basic

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.