diff --git a/docs/proposed/http-storage-node-protocol.rst b/docs/proposed/http-storage-node-protocol.rst index b00b327e3..4d8d60560 100644 --- a/docs/proposed/http-storage-node-protocol.rst +++ b/docs/proposed/http-storage-node-protocol.rst @@ -540,7 +540,7 @@ Rejected designs for upload secrets: Write data for the indicated share. The share number must belong to the storage index. The request body is the raw share data (i.e., ``application/octet-stream``). -*Content-Range* requests are encouraged for large transfers to allow partially complete uploads to be resumed. +*Content-Range* requests are required; for large transfers this allows partially complete uploads to be resumed. For example, a 1MiB share can be divided in to eight separate 128KiB chunks. Each chunk can be uploaded in a separate request. diff --git a/src/allmydata/storage/http_server.py b/src/allmydata/storage/http_server.py index ad1b8b2ac..708b99380 100644 --- a/src/allmydata/storage/http_server.py +++ b/src/allmydata/storage/http_server.py @@ -240,16 +240,13 @@ class HTTPServer(object): """Write data to an in-progress immutable upload.""" content_range = parse_content_range_header(request.getHeader("content-range")) if content_range is None or content_range.units != "bytes": - # TODO Missing header means full upload in one request request.setResponseCode(http.REQUESTED_RANGE_NOT_SATISFIABLE) return b"" - + offset = content_range.start - - # TODO basic check that body isn't infinite. require content-length? or maybe we should require content-range (it's optional now)? if so, needs to be rflected in protocol spec. - - data = request.content.read() + # TODO limit memory usage + data = request.content.read(content_range.stop - content_range.start + 1) try: bucket = self._uploads[storage_index].shares[share_number] except (KeyError, IndexError):