private HTTPResponse(HTTPHeaders headers, ResponseStream stream) { headers.SetHeader("Server", "m9ras Upnp DLNA home media server"); Headers = headers.ToHttp(); Stream = stream; }
/// <summary> /// Create response stream according to data stream and range request. Also inject appropriate range and length headers /// </summary> /// <param name="headers"></param> /// <param name="request"></param> /// <param name="dataStream"></param> /// <param name="dataTotalLength"></param> /// <returns></returns> private static ResponseStream createResponseStream(HTTPHeaders headers, HTTPRequestParser request,Stream dataStream ,long dataTotalLength) { var rangeSelector = request.GetHeader("Range"); var range=new HTTPRange(dataTotalLength,rangeSelector); if (range.IsPartial) //inject range header into response headers headers.SetHeader("Content-Range", string.Format("bytes {0}-{1}/{2}",range.FromBytes,range.ToBytes,range.FileLength)); headers.SetHeader("Content-Length", range.ContentLength.ToString()); return new ResponseStream(dataStream, range.FromBytes, range.ToBytes); }