Phpheader request rewriting

Source: Internet
Author: User
My colleague asked me to help explain a problem: a PHP-generated redirect request generates two completely different records in the Nginx log. the response body size is zero bytes, the other response body size is five bytes. when I am older, my sense of smell is no longer sensitive to problems. first... my colleague asked me to help explain a problem: a PHP-generated redirect request generates two completely different records in the Nginx log. the response body size is zero bytes, the other response body size is five bytes.

Now that I am older, my sense of smell in the face of problems is no longer sensitive. I feel that nothing is correct. I wonder if I forget to quit after redirection, and there is content output later, however, I checked the code and found that there was no problem. The code is as follows:

 

After a large circle, I suddenly realized that the environment was Nginx + PHP and the response was not "Content-Length". The data was sent through "Transfer-Encoding, therefore, the empty response body for redirection is actually similar:

0 \ r \ n

Not many, exactly five bytes. for details, refer to Chunked transfer encoding. in this case, PHP actively outputs a "Content-Length: 0 "may be better.

How can we explain the zero-byte response? Query logs can be found in the following two situations:

HEAD "/path HTTP/1.1" 302 0

GET "/path HTTP/1.0" 302 0

The former is a HEAD request and does not need a response body. The latter is HTTP/1.0 and does not support "Transfer-Encoding 」.

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.