# HTTP protocol learning # (12) Understand forwarding and redirection

Source: Internet
Author: User

This article turns from: vivid and clear http://blog.csdn.net/meiyalei/article/details/2129120

 

Interpretation 1


Forwarding is a server action, and redirection is a client action. Why do we say this? It depends on the workflow of the two actions:

Forwarding process: the client browser sends an HTTP request ---- Web Server accepts this request -- call an internal method to complete request processing and forwarding actions within the container ---- send the target resource to the customer; here, the forwarding path must be a URL under the same Web container, which cannot be switched to another web path, and the request in the container is transmitted in the middle. The path shown in the path bar of the customer's browser is still the path of the first access, that is, the customer does not feel that the server has been forwarded. The forwarding behavior is that the browser only makes one access request.

Redirection process: the client browser sends an HTTP request ---- after the Web Server accepts the request, it sends a 302 status code response and corresponding new location to the client browser -- the client browser finds a 302 response, then a new HTTP request is automatically sent. The request URL is the new location address ---- the server searches for resources based on the request and sends the request to the customer. Here, location can be redirected to any URL. Since the browser resends the request, there is no concept of request transmission. The redirection path is displayed in the path bar of the customer's browser. The customer can observe the address change. Redirection occurs when the browser makes at least two access requests. Sex means that one request and multiple requests to a resource should have the same side effects.

 

Interpretation 2

Redirection is actually two requests,
For the first time, the client requests a, the server responds, and response returns, telling the browser that you should go to B. At this time, ie can see that the address has changed, and the historical rollback button is also on. Redirection allows you to access resources other than your web applications. During redirection, the transmitted information is lost.

Request forwarding means that the server transfers the processing right of a request/response to another
For the client, it only knows the first requested a, not the middle B, or even C, D. The transmitted information will not be lost.

 

Interpretation 3

Suppose you are going to apply for a license,

Redirection: you first went to Bureau A, and the person in Bureau a said, "We don't care about this. Go to Bureau B." Then, you withdrew from Bureau, I took a bus to Bureau B.
Forward: you first went to Bureau A. After Bureau a saw it, you should know that bureau B was in charge of this matter, but he didn't return you back, but asked you to sit down for a while, I contacted the person B in the back office and asked them to handle the problem.

 

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.