Title: http.server does not support HTTP range requests
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.10, Python 3.9
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 2021-02-20 22:02 by DavidBord.

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.

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:

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:

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
msg387429 - (view) Author: David Bordeynik (DavidBord) * Date: 2021-02-20 22:02
I would appreciate a code review - thank you
Date User Action Args
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