<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Nancy.Responses
{
    public class StreamResponse<TModel> : Response
    {
        public StreamResponse(Stream source, string contentType)
        {
            this.Contents = GetStream(source);
            this.ContentType = contentType;
            this.StatusCode = HttpStatusCode.OK;
        }

        private static Action<Stream> GetStream(Stream source)
        {
            return stream =>
            {
                if (source != null && source.CanRead)
                {
                    source.Position = 0;
                    source.CopyTo(stream);
                }
            };
        }
    }
}
<commit_msg>Seek validation added.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Nancy.Responses
{
    public class StreamResponse<TModel> : Response
    {
        public StreamResponse(Stream source, string contentType)
        {
            this.Contents = GetStream(source);
            this.ContentType = contentType;
            this.StatusCode = HttpStatusCode.OK;
        }

        private static Action<Stream> GetStream(Stream source)
        {
            return stream =>
            {
                if (source != null)
                {
                    if (source.CanSeek)
                    {
                        source.Position = 0;
                    }
                    if (source.CanRead)
                    {
                        source.CopyTo(stream);
                    }
                }
            };
        }
    }
}

{'fraction_non_alphanumeric': 0.07932011331444759, 'fraction_numerical': 0.0011331444759206798, 'mean_word_length': 1.2158092848180677, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2217374', 'n_tokens_mistral': 434, 'n_tokens_neox': 422, 'n_words': 87}