示例#1
0
    def _process_file_continue_request(self, request: BaseRequest):
        '''Modify the request to resume downloading file.'''
        if os.path.exists(self._filename):
            size = os.path.getsize(self._filename)
            request.set_continue(size)
            self._file_continue_requested = True

            _logger.debug('Continue file from {0}.', size)
        else:
            _logger.debug('No file to continue.')
示例#2
0
def new_mock_item_session():
    args = argparse.Namespace(directory_prefix='/tmp/')
    app_session = AppSession(None, args, None)
    url_record = new_mock_url_record()
    item_session = ItemSession(app_session, url_record)
    item_session.request = BaseRequest()
    item_session.request.url = 'http://example.com'

    return item_session
示例#3
0
    def process_request(self, request: BaseRequest):
        request = super().process_request(request)

        orig_file = '{0}.orig'.format(self._filename)

        if os.path.exists(orig_file):
            modified_time = os.path.getmtime(orig_file)
        elif os.path.exists(self._filename):
            modified_time = os.path.getmtime(self._filename)
        else:
            modified_time = None

        _logger.debug('Checking for last modified={0}.', modified_time)

        if modified_time:
            date_str = email.utils.formatdate(modified_time)

            request.fields['If-Modified-Since'] = date_str

        return request