Skip to content

bpo-42643: Add support for HTTP range requests#24228

Open
DavidBord wants to merge 2 commits intopython:mainfrom
DavidBord:http-range-requests-bpo-42643
Open

bpo-42643: Add support for HTTP range requests#24228
DavidBord wants to merge 2 commits intopython:mainfrom
DavidBord:http-range-requests-bpo-42643

Conversation

@DavidBord
Copy link
Copy Markdown

@DavidBord DavidBord commented Jan 16, 2021

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 16, 2021
@roolebo
Copy link
Copy Markdown

roolebo commented Feb 20, 2021

@DavidBord Thanks! I think built-in range support is going to be helpful

@stokito
Copy link
Copy Markdown

stokito commented Feb 20, 2021

It’s needed to resume downloads and this may significantly reduce load in some cases. That’s why even minimal busybox httpd has a support of Range requests

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Feb 21, 2021
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Mar 23, 2021
@chrisroat
Copy link
Copy Markdown

This is a most welcome update. Thank you @DavidBord

@imba-tjd
Copy link
Copy Markdown
Contributor

imba-tjd commented Feb 12, 2022

Personally I think it's fundamental to support Range: bytes=<range-start>- i.e. no <range-end>.

Others I think are OK.


I'm using a modified version of this patch in my program https://github.com/imba-tjd/qrsend. I will share info when I found defects.

Comment thread Lib/http/server.py
shutil.copyfileobj(source, outputfile)
if start_byte is not None and end_byte is not None:
source.seek(start_byte)
outputfile.write(source.read(end_byte))
Copy link
Copy Markdown
Contributor

@imba-tjd imba-tjd Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fatal error. When you use 2-5, the start_byte is 2 and end_byte is 5. Then you read(5).
The correct behavior is read(4), which is end_byte-start_byte+1. Though I won't suggest whether putting +1 here or previous place.

More importantly, read() will load all data into memory in a row before start writing. This has serious performance issue when resuming large file. I tried source.truncate() but it turns out an io.UnsupportedOperation.

Besides Content-Length needs changing too. So that new testing is recommended to be added, too.

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 3, 2022
@muxator
Copy link
Copy Markdown

muxator commented Apr 3, 2026

Is there a way to help reviewing this PR? I'd like to help.

@imba-tjd
Copy link
Copy Markdown
Contributor

imba-tjd commented Apr 4, 2026

Is there a way to help reviewing this PR? I'd like to help.

There was another PR which was detailed discussed. However it seems to be deleted. Maybe it will be recoverd.

This PR is poorly implemented and can be closed IMO.

@GalaxySnail
Copy link
Copy Markdown
Contributor

You can use git fetch origin pull/118949/head:pr/118949 to get the code in #118949. The latest commit on this branch is 580aa14. And the latest archive on the Wayback Machine is https://web.archive.org/web/20250925083524/https://github.com/python/cpython/pull/118949.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.