HTTP 206
This week and last week i am working on implementing HTTP 206 and i am using this code : <?php function byteServe($start,$end,$order) Â Â Â Â { $ord = str_split($order); Â Â Â Â $data = " "; Â Â Â Â if($end > count($ord)||$end == null||$end == count($ord)){ Â Â Â Â $end = count($ord)-1; Â Â Â Â } Â Â Â Â for ($x = $start; $x <= $end; $x++) { Â Â Â Â Â Â Â Â $data .= $ord[$x]; Â Â Â Â } Â Â Â Â header('Content-Length: '.strlen($data)); Â Â Â Â header('Content-Range: '.$start .'-'.$end); Â Â Â Â if(substr($data,-1)== '#'){ Â Â Â Â http_response_code(200); Â Â Â Â } Â Â Â Â echo $data; } ?> Its not finished yet and when it is i will post about it again, first some information about what i am doing here. I'm requesting a part of an order that is stored on the server, we send that part with a HTTP response code of 206 which means. Partial Content, this way the requester knows that he can ask for parts of something in bytes, we send content-range so it knows what part it got. This is so it knows from what byte it needs to request and so on until the end.
The last part is send with a response code of 200. this is so that it knows it has all it needs and can go to the next step which can be anything it/you/anybody wants to do with the data. This is how servers can understand pausing and resuming downloads, think of downloading from browsers or even with a torrent client.













