Closed ddevault closed 11 years ago
Please add support for byte ranges (see this document), which will provide better support for HTML5 audio/video.
I've tried to do it myself like this:
var stream = File.OpenRead(Path.Combine(BaseDirectory, path)); response.AddHeader("Accept-Ranges", "bytes"); response.ContentType = HttpServer.GetContentTypeForExtension(Path.GetExtension(path).Substring(1)); // Handle ranges if (request.Headers.Any(h => h.Name == "Range")) { response.StatusCode = 206; response.StatusDescription = "Partial Content"; var range = request.Headers["Range"].Value; var type = range.Remove(range.IndexOf("=")); if (type != "bytes") { response.StatusCode = 400; response.StatusDescription = "Bad Request"; return; } range = range.Substring(range.IndexOf("=") + 1); var rangeParts = range.Split('-'); stream.Seek(int.Parse(rangeParts[0]), SeekOrigin.Begin); } stream.CopyTo(response.Body);
But it doesn't seem to work.
Closing this, since I found some example code in the repository that shows that byte ranges are indeed supported. Maybe a good opportunity to work on better documentation?
Please add support for byte ranges (see this document), which will provide better support for HTML5 audio/video.
I've tried to do it myself like this:
But it doesn't seem to work.