Re: Byte range PATCH

Guoye Zhang <guoye_zhang@apple.com> Sat, 06 August 2022 02:55 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 11FAEC16ECF9 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 5 Aug 2022 19:55:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -8.345
X-Spam-Level:
X-Spam-Status: No, score=-8.345 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.582, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.248, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=apple.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ce2m88OPbdxz for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 5 Aug 2022 19:55:03 -0700 (PDT)
Received: from lyra.w3.org (lyra.w3.org [128.30.52.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2C7BFC157B5D for <httpbisa-archive-bis2Juki@lists.ietf.org>; Fri, 5 Aug 2022 19:55:02 -0700 (PDT)
Received: from lists by lyra.w3.org with local (Exim 4.94.2) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1oK9xC-007Ty2-MR for ietf-http-wg-dist@listhub.w3.org; Sat, 06 Aug 2022 02:54:18 +0000
Resent-Date: Sat, 06 Aug 2022 02:54:18 +0000
Resent-Message-Id: <E1oK9xC-007Ty2-MR@lyra.w3.org>
Received: from mimas.w3.org ([128.30.52.79]) by lyra.w3.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <guoye_zhang@apple.com>) id 1oK9xB-007Tx4-Uk for ietf-http-wg@listhub.w3.org; Sat, 06 Aug 2022 02:54:16 +0000
Received: from ma1-aaemail-dr-lapp03.apple.com ([17.171.2.72]) by mimas.w3.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <guoye_zhang@apple.com>) id 1oK9x8-009J2e-SE for ietf-http-wg@w3.org; Sat, 06 Aug 2022 02:54:16 +0000
Received: from pps.filterd (ma1-aaemail-dr-lapp03.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp03.apple.com (8.16.0.42/8.16.0.42) with SMTP id 2762jDr3063567; Fri, 5 Aug 2022 19:54:02 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=20180706; bh=yJOVeQSMkwTcPikNKBoGWJILx6xj4mQ3wLkHLsjmdOk=; b=kIeUelMn/R4mESgnPUQhjC8FqwORP1ZmKvveCYnJVEr7eSMba2wuWhYbB/Qws6fUZP7G FnamM59E+cDVp3VszbAGCAhqDghyocFNj/VL84775KzZZJ2GUWB432rXkJUAbIjRzMLt 2SGhU/DoWPc5qIsCz5MyTfJZsIf4WF34Zx51rxmg87H0z8odt/sTgsWSSrRUvG7lCymL qChYNOQLapKOQQiwn+w5ueihGihdOCgd7BrasF9OYDz2gjdwD5qluXrMawLZEUkReBaQ FNsZmO7Ou7DT7tajVCaFqVqC+VjLY9lm6ZEI3Rj+uJdmu+R+fDYxMoZLSXnxWXYmj8oq Yg==
Received: from rn-mailsvcp-mta-lapp03.rno.apple.com (rn-mailsvcp-mta-lapp03.rno.apple.com [10.225.203.151]) by ma1-aaemail-dr-lapp03.apple.com with ESMTP id 3hn3mxragc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 05 Aug 2022 19:54:02 -0700
Received: from rn-mailsvcp-mmp-lapp01.rno.apple.com (rn-mailsvcp-mmp-lapp01.rno.apple.com [17.179.253.14]) by rn-mailsvcp-mta-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) with ESMTPS id <0RG6005HTAQ12Z30@rn-mailsvcp-mta-lapp03.rno.apple.com>; Fri, 05 Aug 2022 19:54:01 -0700 (PDT)
Received: from process_milters-daemon.rn-mailsvcp-mmp-lapp01.rno.apple.com by rn-mailsvcp-mmp-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) id <0RG601100AO83O00@rn-mailsvcp-mmp-lapp01.rno.apple.com>; Fri, 05 Aug 2022 19:54:01 -0700 (PDT)
X-Va-A:
X-Va-T-CD: e1c62ae64077d0caba95a15956bd4788
X-Va-E-CD: 35b7e4051558f4c8efb3722a0bb0f060
X-Va-R-CD: f3a918f76ac1401728fa782f7a8bfb67
X-Va-CD: 0
X-Va-ID: 56579876-4677-44d3-a2f1-d2e4528b0e1f
X-V-A:
X-V-T-CD: e1c62ae64077d0caba95a15956bd4788
X-V-E-CD: 35b7e4051558f4c8efb3722a0bb0f060
X-V-R-CD: f3a918f76ac1401728fa782f7a8bfb67
X-V-CD: 0
X-V-ID: aca26bf2-0e1f-48f8-ab3b-ce9257096c04
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.883 definitions=2022-08-06_01:2022-08-04,2022-08-06 signatures=0
Received: from smtpclient.apple (unknown [17.234.15.95]) by rn-mailsvcp-mmp-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) with ESMTPSA id <0RG6008FAAQ1VT00@rn-mailsvcp-mmp-lapp01.rno.apple.com>; Fri, 05 Aug 2022 19:54:01 -0700 (PDT)
Content-type: text/plain; charset="utf-8"
MIME-version: 1.0 (Mac OS X Mail 16.0 \(3731.0.8.1.1\))
From: Guoye Zhang <guoye_zhang@apple.com>
In-reply-to: <20CD5B65-BF7E-4628-B36A-B2DEFFEF4CBE@bzfx.net>
Date: Fri, 05 Aug 2022 19:53:51 -0700
Cc: ietf-http-wg@w3.org
Content-transfer-encoding: quoted-printable
Message-id: <62837B15-2BDB-49EA-B70E-F64B012B94B5@apple.com>
References: <E511F4BD-B422-46DA-8409-EBBD684098A6@bzfx.net> <3A341B75-7088-4B8F-96CC-AB25CAC7D842@apple.com> <20CD5B65-BF7E-4628-B36A-B2DEFFEF4CBE@bzfx.net>
To: Austin William Wright <aaa@bzfx.net>
X-Mailer: Apple Mail (2.3731.0.8.1.1)
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.883 definitions=2022-08-06_01:2022-08-04,2022-08-06 signatures=0
Received-SPF: pass client-ip=17.171.2.72; envelope-from=guoye_zhang@apple.com; helo=ma1-aaemail-dr-lapp03.apple.com
X-W3C-Hub-DKIM-Status: validation passed: (address=guoye_zhang@apple.com domain=apple.com), signature is good
X-W3C-Hub-Spam-Status: No, score=-7.0
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.573, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, W3C_AA=-1, W3C_WL=-1
X-W3C-Scan-Sig: mimas.w3.org 1oK9x8-009J2e-SE 478338d975ad23ea373a56baedaecce8
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Byte range PATCH
Archived-At: <https://www.w3.org/mid/62837B15-2BDB-49EA-B70E-F64B012B94B5@apple.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/40309
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <https://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>


> On Aug 5, 2022, at 19:17, Austin William Wright <aaa@bzfx.net> wrote:
> 
> 
> 
>> On Aug 5, 2022, at 17:12, Guoye Zhang <guoye_zhang@apple.com> wrote:
>> 
>> Hi Austin,
>> 
>> Thanks for sharing the well-written draft. I’m glad this is being worked on. Two comments:
>> 
>> (1) As you have already noted, Content-Range forces us to declare an end offset, so it’s unfortunate that a continuous stream with undetermined length has to be sent using multipart encoding.
> 
> Yeah. I think the best case is Content-Range is updated to support an indefinite length form.
> 
> But a new header could also be defined, like Content-Offset.
> 
>> 
>> (2) For a general purpose byte range patching mechanism, would you also want to define ways to insert or delete byte ranges?
>> 
>> A possible approach is to have this be a “replace byte range with” operation instead:
>> 
>> Replace 0-0 with 100 bytes: insert 100 bytes at the front
>> Replace 0-100 with 0 bytes: remove first 100 bytes
>> Replace 100-100 with 100 bytes: insert 100 bytes at offset 100
> 
> 
> This makes sense!
> 
> The server would have to have some way to recognize that the bytes after it are shifting around (e.g. When prepending 100 bytes, byte 0 becomes byte 100), and reject if that’s too much work, or if the filesystem doesn’t support such an operation. Maybe in this situation, the Content-Length header would be required, and then the server could immediately determine if this is a simple overwrite, or if it's actually changing the file size.

Thinking about this more, there is a problem with using Content-Range for this as well. End offset is inclusive, so in order to insert / append, we need to decrease it by one.

Suppose we have a 100 byte file:

	PATCH /file
	Content-Range: bytes 99-99/100
	Content-Length: 42
This means replacing the last byte with 42 bytes.

	PATCH /file
	Content-Range: bytes 100-99/100
	Content-Length: 42
This means appending 42 bytes in the end.

Having end position being smaller than the start position is already hazardous, where it breaks down is inserting at the beginning:

	PATCH /file
	Content-Range: bytes 0--1/100
	Content-Length: 42
End offset is now -1 and this will definitely trip over existing parsers.

Well, it’s a nice thought. It won’t work unless Content-Range is changed, either.

Guoye
> 
> Thanks,
> 
> Austin.
> 
>