<commit_before>import meinheld

class FileWrapper(object):

    def __init__(self, file, buffer_size=8192):
        self.file = file
        self.buffer_size = buffer_size

    def close(self):
        if hasattr(self.file, 'close'):
            self.file.close()

    def __iter__(self):
        return self

    def next(self):
        data = self.file.read(self.buffer_size)
        if data:
            return data
        raise StopIteration()


def simple_app(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-type','image/jpeg')]
    start_response(status, response_headers)
    # use sendfile(2)
    return environ.get('wsgi.file_wrapper', FileWrapper)(open('wallpaper.jpg', 'rb'))


meinheld.listen(("0.0.0.0", 8000))
#meinheld.access_log('/tmp/acc.log')
#meinheld.error_log('/tmp/err.log')
meinheld.run(simple_app)
<commit_msg>Set Content-Length<commit_after>import meinheld

class FileWrapper(object):

    def __init__(self, file, buffer_size=8192):
        self.file = file
        self.buffer_size = buffer_size

    def close(self):
        if hasattr(self.file, 'close'):
            self.file.close()

    def __iter__(self):
        return self

    def next(self):
        data = self.file.read(self.buffer_size)
        if data:
            return data
        raise StopIteration()


def simple_app(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-type','image/jpeg'), ('Content-Length', '137823')]
    start_response(status, response_headers)
    # use sendfile(2)
    return environ.get('wsgi.file_wrapper', FileWrapper)(open('wallpaper.jpg', 'rb'))


meinheld.listen(("0.0.0.0", 8000))
#meinheld.access_log('/tmp/acc.log')
#meinheld.error_log('/tmp/err.log')
meinheld.run(simple_app)

{'fraction_non_alphanumeric': 0.13987591652566272, 'fraction_numerical': 0.02143260011280316, 'mean_word_length': 3.164319248826291, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6163276', 'n_tokens_mistral': 615, 'n_tokens_neox': 583, 'n_words': 109}