refactor(media): upload pieces are PUT, not PATCH
A piece at an offset is idempotent, which is what PUT means. Java's HttpURLConnection, which the Kotlin port uses, refuses PATCH outright. nginx also retries PUT on the next upstream by default but never PATCH, so the docs now only ask for non_idempotent on the start/status POST. The protocol is unreleased, so nothing else depends on the old method. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -194,7 +194,7 @@ export class MediaClient {
|
||||
const length = Math.min(chunk, size - offset);
|
||||
const piece = await cut(offset, offset + length);
|
||||
const res = await send({
|
||||
method: 'PATCH',
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'content-type': 'application/octet-stream',
|
||||
'content-length': String(length),
|
||||
@@ -256,7 +256,7 @@ export class MediaClient {
|
||||
// that failed and was retried): an empty piece at the end finishes it.
|
||||
await retrying(async () => {
|
||||
const res = await send({
|
||||
method: 'PATCH',
|
||||
method: 'PUT',
|
||||
headers: { 'content-length': '0', [OFFSET_HEADER]: String(size), ...this.owner.headers({ op: 'piece', id, offset: size, length: 0 }) },
|
||||
});
|
||||
if (res.status !== 201) return fail(res, 'finish');
|
||||
|
||||
Reference in New Issue
Block a user