(payload, content_length, content_format, filename, request=None)
return response
:param payload: File like object.
    :param content_length: Size of payload in bytes
    :param content_format: ``couchexport.models.Format`` instance
    :param filename: Name of the download
    :param request: The request. Used to determine if a range response should be given.
    :return: HTTP response
:param payload: File like object.
    :param content_length: Size of payload in bytes
    :param content_format: ``couchexport.models.Format`` instance
    :param filename: Name of the download
    :param request: The request. Used to determine if a range response should be given.
    :return: HTTP response
: param payload : File like object . : param content_length : Size of payload in bytes : param content_format : couchexport . models . Format instance : param filename : Name of the download : param request : The request . Used to determine if a range response should be given . : return : HTTP response
def get_download_response(payload, content_length, content_format, filename, request=None):
    """
    :param payload: File like object.
    :param content_length: Size of payload in bytes
    :param content_format: ``couchexport.models.Format`` instance
    :param filename: Name of the download
    :param request: The request. Used to determine if a range response should be given.
    :return: HTTP response
    """
    ranges = None
    if request and "HTTP_RANGE" in request.META:
        try:
            ranges = parse_range_header(request.META['HTTP_RANGE'], content_length)
        except ValueError:
            pass

    if ranges and len(ranges.ranges) != 1:
        ranges = None

    response = StreamingHttpResponse(content_type=content_format.mimetype)
    if content_format.download:
        response['Content-Disposition'] = safe_filename_header(filename)

    response["Content-Length"] = content_length
    response["Accept-Ranges"] = "bytes"

    if ranges:
        start, stop = ranges.ranges[0]
        if stop is not None and stop > content_length:
            # requested range not satisfiable
            return HttpResponse(status=416)

        response.streaming_content = RangedFileWrapper(payload, start=start, stop=stop or float("inf"))
        end = stop or content_length
        response["Content-Range"] = "bytes %d-%d/%d" % (start, end - 1, content_length)
        response["Content-Length"] = end - start
        response.status_code = 206
    else:
        response.streaming_content = FileWrapper(payload)

    return response
def get_download_response ( payload , content_length , content_format , filename , request = None ) : ranges = None if request and "HTTP_RANGE" in request . META : try : ranges = parse_range_header ( request . META [ 'HTTP_RANGE' ] , content_length ) except ValueError : pass if ranges and len ( ranges . ranges ) != 1 : ranges = None response = StreamingHttpResponse ( content_type = content_format . mimetype ) if content_format . download : response [ 'Content-Disposition' ] = safe_filename_header ( filename ) response [ "Content-Length" ] = content_length response [ "Accept-Ranges" ] = "bytes" if ranges : start , stop = ranges . ranges [ 0 ] if stop is not None and stop > content_length : # requested range not satisfiable return HttpResponse ( status = 416 ) response . streaming_content = RangedFileWrapper ( payload , start = start , stop = stop or float ( "inf" ) ) end = stop or content_length response [ "Content-Range" ] = "bytes %d-%d/%d" % ( start , end - 1 , content_length ) response [ "Content-Length" ] = end - start response . status_code = 206 else : response . streaming_content = FileWrapper ( payload ) return response