About the record of HTTP code 308

Time:2019-12-7

Recently, a file upload function is needed in the project. The component used is element
During the test, the upload component of UI found that the status returned by the backend is 308 permanent redirection. During the upload process, not only the request to upload the file itself, but also aSeemIrrelevant requests, through the query of data, finally found out why the upload failed and the meaning of 308 status code

As shown in the figure, it is a screenshot of the request at that time:

About the record of HTTP code 308

Figure 1Upload request
About the record of HTTP code 308

Figure 2Redirecting Requests

This article has been found by searching information on the Internet. The article has explained the meaning of 308 status code clearly, that is, the requested address has been permanently redirected to another URI, and there will be a header called “location” in the response headers returned by the request to indicate the redirected location.

The reason why I failed to upload here is that the interface address should have been “/ security / file /”, but I wrote “/ security / file”, with one “/” missing behind the address. Therefore, as shown in Figure 1, the “location” in response headers indicates the location of redirection, which is the request in Figure 2.

Here, the first two file requests are the same. As for why they appear twice, we haven’t figured out the reason. Because Chrome browser is advanced, will it automatically try one more request? In fact, in ie, only one upload request will appear, and the next two will not appear, as shown in Figure 3. In Firefox, file is requested once, and resource is redirected once, as shown in Figure 4.
About the record of HTTP code 308
Figure 3All requests in IE
About the record of HTTP code 308
Figure 4All requests in Firefox

There is also an unclear problem here. The request in Figure 2 is actually a configuration of the backend in Apache. It needs to be further determined why it is redirected here.