The Http://127.0.0.1:20301/x.zip file is staged for download, and the service side is not required. Use the Range parameter to segment. Look at the code below:
<?php $fp = Fsockopen ("127.0.0.1", 20301, $errno, $errstr, 30); if (! $fp) {echo $errstr ($errno) <br/>/n ";} else {# first download $out =" Get/x.zip http/1.1/r/n "; $out. =" range:0-10/ r/n "; $out. = "host:127.0.0.1/r/n"; $out. = "connection:close/r/n/r/n"; Fwrite ($fp, $out); $start = false; while (!feof ($fp)) {$line = Fgets ($FP); if (! $start && ("/r/n" = = $line | | ' n ' = = $line)} {$start = true; continue} if ($start) {fwrite (fopen ('./a.zip ', ' WB '), $line);} # the second download $out = "Get/x.zip http/1.1/r/n"; $out. = "range:11-/r/n"; $out. = "host:127.0.0.1/r/n"; $out. = "connection:close/r/n/r/n"; Fwrite ($fp, $out); $start = false; while (!feof ($fp)) {$line = Fgets ($FP); if (! $start && ("/r/n" = = $line | | ' n ' = = $line)} {$start = true; continue} if ($start) {fwrite (fopen ('./a.zip ', ' WB '), $line);} Fclose ($FP); }
The header information is removed every time a request is written to a file. However, the test looks like the first paragraph can write header information. You can try it yourself, this is just a simple example.