From 0c9e658c731489e984b8bf14664f717ade8332bb Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 19 May 2023 08:08:36 -0700 Subject: [PATCH] Record unbound Range requests only, don't convert bounded range requests to unbounded (#845) * record fix: don't convert 0-N range requests to unbounded for recording, only record 0- (unbounded range requests) * tests: attempt to fix tests, disable youtube-dl related tests * bump to 2.7.4 --- .github/workflows/ci.yaml | 6 +++--- pywb/apps/rewriterapp.py | 4 ++-- pywb/version.py | 2 +- pywb/warcserver/test/test_handlers.py | 6 ++++-- tests/test_live_rewriter.py | 3 ++- tests/test_range.py | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c48092cd..1a499d14 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,10 +12,10 @@ jobs: steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -28,5 +28,5 @@ jobs: run: tox - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 diff --git a/pywb/apps/rewriterapp.py b/pywb/apps/rewriterapp.py index a0292732..fe40b4ee 100644 --- a/pywb/apps/rewriterapp.py +++ b/pywb/apps/rewriterapp.py @@ -248,8 +248,8 @@ class RewriterApp(object): range_start = start range_end = end - # if start with 0, load from upstream, but add range after - if start == 0: + # if start with 0 and no end, load from upstream + if start == 0 and not end: del inputreq.env['HTTP_RANGE'] else: skip_record = True diff --git a/pywb/version.py b/pywb/version.py index 6b4cc26e..5fc13460 100644 --- a/pywb/version.py +++ b/pywb/version.py @@ -1,4 +1,4 @@ -__version__ = '2.7.3' +__version__ = '2.7.4' if __name__ == '__main__': print(__version__) diff --git a/pywb/warcserver/test/test_handlers.py b/pywb/warcserver/test/test_handlers.py index 74a4a0a9..47d0da53 100644 --- a/pywb/warcserver/test/test_handlers.py +++ b/pywb/warcserver/test/test_handlers.py @@ -385,7 +385,8 @@ foo=bar&test=abc""" assert resp.headers['Warcserver-Source-Coll'] == 'url-agnost' assert resp.headers['Memento-Datetime'] == 'Mon, 29 Jul 2013 19:51:51 GMT' - @pytest.mark.skipif(os.environ.get('CI') is not None, reason='Skip Test on CI') + #@pytest.mark.skipif(os.environ.get('CI') is not None, reason='Skip Test on CI') + @pytest.mark.skip("youtube-dl update needed") def test_live_video_loader(self): pytest.importorskip('youtube_dl') params = {'url': 'http://www.youtube.com/v/BfBgWtAIbRc', @@ -404,7 +405,8 @@ foo=bar&test=abc""" assert b'WARC-Type: metadata' in resp.body assert b'Content-Type: application/vnd.youtube-dl_formats+json' in resp.body - @pytest.mark.skipif(os.environ.get('CI') is not None, reason='Skip Test on CI') + #@pytest.mark.skipif(os.environ.get('CI') is not None, reason='Skip Test on CI') + @pytest.mark.skip("youtube-dl update needed") def test_live_video_loader_post(self): pytest.importorskip('youtube_dl') req_data = """\ diff --git a/tests/test_live_rewriter.py b/tests/test_live_rewriter.py index 0fbe2c5f..5b8eac65 100644 --- a/tests/test_live_rewriter.py +++ b/tests/test_live_rewriter.py @@ -169,7 +169,8 @@ class TestLiveRewriter(HttpBinLiveTests, BaseConfigTest): resp = resp.follow(status=400) assert resp.status_int == 400 - @pytest.mark.skipif(os.environ.get('CI') is not None, reason='Skip Test on CI') + #@pytest.mark.skipif(os.environ.get('CI') is not None, reason='Skip Test on CI') + @pytest.mark.skip("youtube-dl update needed") def test_live_video_info(self): pytest.importorskip('youtube_dl') resp = self.testapp.get('/live/vi_/https://www.youtube.com/watch?v=DjFZyFWSt1M') diff --git a/tests/test_range.py b/tests/test_range.py index a9d6c449..38ffbb26 100644 --- a/tests/test_range.py +++ b/tests/test_range.py @@ -29,7 +29,7 @@ class TestReplayRange(BaseConfigTest): assert resp.headers['Content-Range'] == 'bytes 0-200/1270', resp.headers['Content-Range'] assert resp.content_length == 201, resp.content_length - assert self.recorder_skip == None + assert self.recorder_skip == '1' assert 'wombat.js' not in resp.text