May I ask questions about the HTTP response header when uploading a previous file?

Source: Internet
Author: User
For more information, see the HTTP response header when downloading files. When I learned how to use PHP to download files, the textbook said that three http message headers are required: PHPcodeheader (& quot; Content-type: applicationoctet-stream & quot ;); the high-speed browser transmits the File Stream header (& quot; Acce asks about the HTTP response header when the file is downloaded.
When I learned how to use PHP to download files, the textbook said that three http message headers should be provided:
PHP code
  Header ("Content-type: application/octet-stream"); // The high-speed browser transmits the file stream header ("Accept-Length: 2048 "); // file size header ("Content-Disposition: attachment; filename=abc.txt"); // specify the file name


The message headers "Content-type" and "Content-Disposition" are not quite understandable, so I have made two examples:

A. php:
PHP code
  
  


B. php:
PHP code
  
  


My problem is:
1. there is one missing message header on both pages. Why can all files be downloaded successfully?
2. although the size of the specified file is 2048 bytes, the actual output is only "123". Why can the file be downloaded normally?
Is the "Accept-Length" message header configurable?

I have just learned about http. please answer the questions I have asked. do not introduce a deeper concept because I cannot understand it ..
Thank you! :)

------ Solution --------------------
1. there is one missing message header on both pages. Why can all files be downloaded successfully?

Because you have not set the Content-Length, the output at the end of the default connection is the downloaded Content.

2. although the size of the specified file is 2048 bytes, the actual output is only "123". Why can the file be downloaded normally? Is the "Accept-Length" message header configurable?

Accept-Length indicates the maximum acceptable string Length. So it can be set.

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.