This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: http.server does not support HTTP range requests
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: DavidBord, Decorater, sblondon
Priority: normal Keywords: patch

Created on 2020-12-15 02:24 by Decorater, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 24228 open DavidBord, 2021-01-16 12:54
Messages (4)
msg383028 - (view) Author: Decorater (Decorater) * Date: 2020-12-15 02:24
I have issues with range requests on http.server module (ran from python -m http.server command)

When requesting files to download from an program written in C (which uses range requests to update an progress bar) it ignores this and simply forces download of the entire thing at once) which in turn on my program makes the progress bar never update to display the progress of the download to the user.

https://tools.ietf.org/id/draft-ietf-httpbis-p5-range-09.html#range.units

It is a part from HTTP/1.1, I think this would be something good to actually have to support partial requests (if they request an range in the header of their request), for directory listings (which can be used to download files from), it could be considered helpful it be able to request specific byte ranges inside of the files to download at a time to split up bandwidth to not overwhelm an file server.
msg383029 - (view) Author: Decorater (Decorater) * Date: 2020-12-15 02:28
It seems there are some packages that supports the range requests too:

https://github.com/danvk/RangeHTTPServer

Not sure if that supports python 3 or not. It could be used to make a patch for http.server though.
msg383685 - (view) Author: Stéphane Blondon (sblondon) * Date: 2020-12-24 12:30
RangeHTTPServer seems to support python3: there is a try-except clause to manage the different import of SimpleHTTPServer:
https://github.com/danvk/RangeHTTPServer/blob/master/RangeHTTPServer/__main__.py#L13

The code is under Apache 2.0 licence. I don't know if it can be integrated in codebase under the PSF licence.

Another question needs to be answered previously: does the maintainers want to add such feature to SimpleHTTPServer (which goal is to be very basic)? They could prefer to add a header refusing the Range header:
Accept-Ranges: none

https://tools.ietf.org/id/draft-ietf-httpbis-p5-range-09.html#header.accept-ranges
msg387429 - (view) Author: David Bordeynik (DavidBord) * Date: 2021-02-20 22:02
I would appreciate a code review - thank you
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86809
2021-02-20 22:02:16DavidBordsetmessages: + msg387429
2021-01-16 12:54:48DavidBordsetkeywords: + patch
nosy: + DavidBord

pull_requests: + pull_request23051
stage: patch review
2020-12-24 12:30:20sblondonsetnosy: + sblondon
messages: + msg383685
2020-12-15 02:28:47Decoratersetmessages: + msg383029
2020-12-15 02:24:06Decoratercreate