public void SendBody(HttpMethod requestHttpMethod, HttpResponseBase response, ITransmitEntityStrategy transmitEntity)
        {
            if (requestHttpMethod == HttpMethod.Head)
            {
                return;
            }

            if (requestHttpMethod != HttpMethod.Get)
            {
                throw new Exception("Unsupported http method");
            }

            TransmitMultiPartFile(response, transmitEntity.Entity.ContentType, transmitEntity.Entity.ContentLength, Ranges, transmitEntity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends entity to response body.
        /// </summary>
        /// <param name="requestHttpMethod">The http method for the HTTP request.</param>
        /// <param name="response">An HTTP response.</param>
        /// <param name="transmitEntity">The strategy to use to transmit entity to http response.</param>
        public void SendBody(HttpMethod requestHttpMethod, HttpResponseBase response, ITransmitEntityStrategy transmitEntity)
        {
            if (requestHttpMethod == HttpMethod.Head)
            {
                return;
            }

            if (requestHttpMethod != HttpMethod.Get)
            {
                throw new Exception("Unsupported http method");
            }

            transmitEntity.Transmit(response);
        }
        public void SendBody(HttpMethod requestHttpMethod, HttpResponseBase response, ITransmitEntityStrategy transmitEntity)
        {
            if (requestHttpMethod == HttpMethod.Head)
            {
                return;
            }

            if (requestHttpMethod != HttpMethod.Get)
            {
                throw new Exception("Unsupported http method");
            }

            var bytesToRead = Range.EndRange - Range.StartRange + 1;
            transmitEntity.Transmit(response, Range.StartRange, bytesToRead);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sends entity to response body.
        /// </summary>
        /// <param name="requestHttpMethod">The http method for the HTTP request.</param>
        /// <param name="response">An HTTP response.</param>
        /// <param name="transmitEntity">The strategy to use to transmit entity to http response.</param>
        public void SendBody(HttpMethod requestHttpMethod, HttpResponseBase response, ITransmitEntityStrategy transmitEntity)
        {
            if (requestHttpMethod == HttpMethod.Head)
            {
                return;
            }

            if (requestHttpMethod != HttpMethod.Get)
            {
                throw new Exception("Unsupported http method");
            }

            transmitEntity.Transmit(response);
        }
        public void SendBody(HttpMethod requestHttpMethod, HttpResponseBase response, ITransmitEntityStrategy transmitEntity)
        {
            if (requestHttpMethod == HttpMethod.Head)
            {
                return;
            }

            if (requestHttpMethod != HttpMethod.Get)
            {
                throw new Exception("Unsupported http method");
            }

            TransmitMultiPartFile(response, transmitEntity.Entity.ContentType, transmitEntity.Entity.ContentLength, Ranges, transmitEntity);
        }
        /// <summary>
        /// Transmit file ranges to browser,
        /// </summary>
        /// <param name="response">The <see cref="HttpResponse" /> of the current HTTP request.</param>
        /// <param name="contentType">The content type of the entity.</param>
        /// <param name="contentLength">The length of the entity.</param>
        /// <param name="ranges">A list of ranges to send to the browser.</param>
        /// <param name="transmitEntity"></param>
        protected virtual void TransmitMultiPartFile(HttpResponseBase response, string contentType, long contentLength, IEnumerable <RangeItem> ranges, ITransmitEntityStrategy transmitEntity)
        {
            foreach (var range in ranges)
            {
                var multiPartHeader = GenerateMultiPartHeader(contentType, contentLength, range.StartRange, range.EndRange);
                response.Output.Write(multiPartHeader);

                var bytesToRead = range.EndRange - range.StartRange + 1;
                transmitEntity.Transmit(response, range.StartRange, bytesToRead);
                transmitEntity.TransmitComplete(response);
            }
            var multiPartFooter = GenerateMultiPartFooter();

            response.Output.Write(multiPartFooter);
        }
 /// <summary>
 /// Sends ranges of a stream to the browser.
 /// </summary>
 /// <param name="requestHttpMethod">The http method for the HTTP request.</param>
 /// <param name="response">An HTTP response.</param>
 /// <param name="transmitEntity"></param>
 public void SendBody(HttpMethod requestHttpMethod, HttpResponseBase response, ITransmitEntityStrategy transmitEntity)
 {
     ByteRangeResponse.SendBody(requestHttpMethod, response, transmitEntity);
 }
Exemplo n.º 8
0
        public void SendBody(HttpMethod requestHttpMethod, HttpResponseBase response, ITransmitEntityStrategy transmitEntity)
        {
            if (requestHttpMethod == HttpMethod.Head)
            {
                return;
            }

            if (requestHttpMethod != HttpMethod.Get)
            {
                throw new Exception("Unsupported http method");
            }

            var bytesToRead = Range.EndRange - Range.StartRange + 1;

            transmitEntity.Transmit(response, Range.StartRange, bytesToRead);
        }
        /// <summary>
        /// Transmit file ranges to browser,
        /// </summary>
        /// <param name="response">The <see cref="HttpResponse" /> of the current HTTP request.</param>
        /// <param name="contentType">The content type of the entity.</param>
        /// <param name="contentLength">The length of the entity.</param>
        /// <param name="ranges">A list of ranges to send to the browser.</param>
        /// <param name="transmitEntity"></param>
        protected virtual void TransmitMultiPartFile(HttpResponseBase response, string contentType, long contentLength, IEnumerable<RangeItem> ranges, ITransmitEntityStrategy transmitEntity)
        {
            foreach (var range in ranges)
            {
                var multiPartHeader = GenerateMultiPartHeader(contentType, contentLength, range.StartRange, range.EndRange);
                response.Output.Write(multiPartHeader);

                var bytesToRead = range.EndRange - range.StartRange + 1;
                transmitEntity.Transmit(response, range.StartRange, bytesToRead);
                transmitEntity.TransmitComplete(response);
            }
            var multiPartFooter = GenerateMultiPartFooter();
            response.Output.Write(multiPartFooter);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Sends ranges of a stream to the browser.
 /// </summary>
 /// <param name="requestHttpMethod">The http method for the HTTP request.</param>
 /// <param name="response">An HTTP response.</param>
 /// <param name="transmitEntity"></param>
 public void SendBody(HttpMethod requestHttpMethod, HttpResponseBase response, ITransmitEntityStrategy transmitEntity)
 {
     ByteRangeResponse.SendBody(requestHttpMethod, response, transmitEntity);
 }