PATCH vs multipart/byteranges vs Content-Range

Hi,

I was in the process of putting together an example of using 
multipart/byteranges as a payload for the PATCH method when I realized 
that RFC2616 requires that format to at least contain two parts (partial 
responses in RFC2616 do not need multipart when there's only a single part).

So, to overwrite a single range of bytes, one would need a dummy (empty) 
part, unless...

...it's ok to use Content-Range as a request header.

Looking at 
<http://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.14.16>:

"The Content-Range entity-header is sent with a partial entity-body to 
specify where in the full entity-body the partial body should be applied."

So, to append a line of text to a representation with a current 
Content-Length of 1234 bytes, would it be ok to use

---
PATCH /test.txt HTTP/1.1
Host: example.com
Content-Type: text/plain
Content-Range: 1234-1245/1234
Content-Length: 12

0123456789
---

(where the line to be appended ends in CRLF, thus counting 12 bytes).

Questions:

1) Would it be OK to use Content-Range on PATCH (understanding people 
previously were reluctant to use it on PUT because servers may ignore 
it, thus truncate a resource)?

2) Should instance-length be the length *before* or *after* applying the 
  request (I'd assume *before*). Or should it just use "*"? (*)

3) Should we mention this in the PATCH spec; minimally requiring servers 
to either reject requests with Content-Range headers, or to process the 
payload as a partial replace?

BR, Julian

(*) This would not be a problem for any partial update that doesn't 
change the length.

Received on Saturday, 16 February 2008 11:30:37 UTC