Skip to content

gh-86809: Add support for HTTP Range header in HTTPServer #118949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Split testcases
  • Loading branch information
lyc8503 committed Jan 12, 2025
commit 7c94aae7e20f466874658eafa89c7d53f9d8e907
17 changes: 9 additions & 8 deletions Lib/test/test_httpservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def test_get(self):
finally:
os.chmod(self.tempdir, 0o755)

def test_range_get(self):
def test_single_range_get(self):
route = self.base_url + '/test'
response = self.request(route)
self.assertEqual(response.getheader('accept-ranges'), 'bytes')
Expand Down Expand Up @@ -592,13 +592,9 @@ def test_range_get(self):
response = self.request(route, headers={'Range': 'bytes='})
self.check_status_and_reason(response, HTTPStatus.OK, data=self.data)

# multipart ranges (not supported currently)
response = self.request(route, headers={'Range': 'bytes=1-2, 4-7'})
self.check_status_and_reason(response, HTTPStatus.OK, data=self.data)

# empty file
with open(os.path.join(self.tempdir_name, 'empty'), 'wb'):
pass
def test_single_range_get_empty(self):
# range requests to an empty file
os_helper.create_empty_file(os.path.join(self.tempdir_name, 'empty'))
empty_path = self.base_url + '/empty'

response = self.request(empty_path, headers={'Range': 'bytes=0-512'})
Expand All @@ -611,6 +607,11 @@ def test_range_get(self):
self.assertEqual(response.getheader('content-range'), 'bytes */0')
self.check_status_and_reason(response, HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE)

def test_multi_range_get(self):
# multipart ranges (not supported currently)
response = self.request(self.base_url + '/test', headers={'Range': 'bytes=1-2, 4-7'})
self.check_status_and_reason(response, HTTPStatus.OK, data=self.data)

def test_head(self):
response = self.request(
self.base_url + '/test', method='HEAD')
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy