Range support is broken. The test isset always returns true because the explode function will return empty strings if nothin is specified. As a result if parts[0] is an empty string no start is set; same for the endpoint. This is fixed here. Furthermore if the start is not specified, the range must be applied to the end of the file as specified in the the http 1.1 standard. Finally I added brackets to avoid malformed headers.