<commit_before>import os
import stat
import re
from email.Utils import parsedate_tz, mktime_tz

from django.core.files.base import File
from django.http import HttpResponse, HttpResponseNotModified
from django.utils.http import http_date

try:
    # New in Django 1.5
    from django.http import StreamingHttpResponse
except ImportError:
    StreamingHttpResponse = None


def sendfile(request, filename, **kwargs):
    # Respect the If-Modified-Since header.
    statobj = os.stat(filename)

    if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),
                              statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]):
        return HttpResponseNotModified()

    if StreamingHttpResponse is None:
        # Django < 1.5
        response = HttpResponse(File(open(filename, 'rb')))
        response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])
        return

    fileiter = _FileStreamer(filename)

    response = StreamingHttpResponse(fileiter)
    response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])
    response['Accept-Ranges'] = 'bytes'

    # Parse range request, if any
    start = None
    stop = None

    range_request = request.META.get('HTTP_RANGE', '').strip()
    m = re.match(r'^bytes=(?P<start>\d+)?-(?P<stop>\d+)?$', range_request)<commit_msg>mediasnake_sendfile: Don't unconditionally set Accept-Ranges<commit_after>import os
import stat
import re
from email.Utils import parsedate_tz, mktime_tz

from django.core.files.base import File
from django.http import HttpResponse, HttpResponseNotModified
from django.utils.http import http_date

try:
    # New in Django 1.5
    from django.http import StreamingHttpResponse
except ImportError:
    StreamingHttpResponse = None


def sendfile(request, filename, **kwargs):
    # Respect the If-Modified-Since header.
    statobj = os.stat(filename)

    if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),
                              statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]):
        return HttpResponseNotModified()

    if StreamingHttpResponse is None:
        # Django < 1.5
        response = HttpResponse(File(open(filename, 'rb')))
        response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])
        return

    fileiter = _FileStreamer(filename)

    response = StreamingHttpResponse(fileiter)
    response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])

    # Parse range request, if any
    start = None
    stop = None

    range_request = request.META.get('HTTP_RANGE', '').strip()
    m = re.match(r'^bytes=(?P<start>\d+)?-(?P<stop>\d+)?$', range_request)
{'fraction_non_alphanumeric': 0.10966755827283149, 'fraction_numerical': 0.003056935422239205, 'mean_word_length': 3.70863309352518, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3854367', 'n_tokens_mistral': 824, 'n_tokens_neox': 797, 'n_words': 179}