human
Complete this python program:
def _serve_fileobj(fileobj, content_type, content_length, debug=False):
assistant
#Here is the Python code you requested.

    """Internal. Set response.body to the given file object, perhaps ranged.
    """
    response = cherrypy.serving.response
    request = cherrypy.serving.request
    if (request.protocol >= (1, 1)):
        response.headers['Accept-Ranges'] = 'bytes'
        r = httputil.get_ranges(request.headers.get('Range'), content_length)
        if (r == []):
            response.headers['Content-Range'] = ('bytes    */%s' % content_length)
            message = 'Invalid    Range    (first-byte-pos    greater    than    Content-Length)'
            if debug:
                cherrypy.log(message, 'TOOLS.STATIC')
            raise cherrypy.HTTPError(416, message)
        if r:
            if (len(r) == 1):
                (start, stop) = r[0]
                if (stop > content_length):
                    stop = content_length
                r_len = (stop - start)
                if debug:
                    cherrypy.log(('Single    part;    start:    %r,    stop:    %r' % (start, stop)), 'TOOLS.STATIC')
                response.status = '206    Partial    Content'
                response.headers['Content-Range'] = ('bytes    %s-%s/%s' % (start, (stop - 1), content_length))
                response.headers['Content-Length'] = r_len
                fileobj.seek(start)
                response.body = file_generator_limited(fileobj, r_len)
            else:
                response.status = '206    Partial    Content'
                try:
                    from email.generator import _make_boundary as make_boundary
                except ImportError:
                    from mimetools import choose_boundary as make_boundary
                boundary = make_boundary()
                ct = ('multipart/byteranges;    boundary=%s' % boundary)
                response.headers['Content-Type'] = ct
                if ('Content-Length' in response.headers):
                    del response.headers['Content-Length']
                def file_ranges():
                    (yield ntob('\r\n'))
                    for (start, stop) in r:
                        if debug:
                           ...