+2
-2
README.md
+2
-2
README.md
···
80
- A directory entry replaces any existing file or directory with the same name (if any), recursively removing the old contents.
81
- A file or symlink entry replaces any existing file or directory with the same name (if any).
82
- In any case, the parent of an entry must exist and be a directory.
83
-
- The request must have a `Race-Free: yes` or `Race-Free: no` header. Not every backend configuration makes it possible to perform atomic compare-and-swap operations; on backends without atomic CAS support, `Race-Free: yes` requests will fail, while `Race-Free: no` requests will provide a best-effort approximation.
84
-
- If a `PATCH` request loses a race against another content update request, it may return `409 Conflict`. This is true regardless of the `Race-Free:` header value. Whenever this happens, resubmit the request as-is.
85
- If the site has no contents after the update is applied, performs the same action as `DELETE`.
86
* In response to a `DELETE` request, the server unpublishes a site. The URL of the request must be the root URL of the site that is being unpublished. Site data remains stored for an indeterminate period of time, but becomes completely inaccessible.
87
* If a `Dry-Run: yes` header is provided with a `PUT`, `PATCH`, `DELETE`, or `POST` request, only the authorization checks are run; no destructive updates are made. Note that this functionality was added in _git-pages_ v0.2.0.
···
80
- A directory entry replaces any existing file or directory with the same name (if any), recursively removing the old contents.
81
- A file or symlink entry replaces any existing file or directory with the same name (if any).
82
- In any case, the parent of an entry must exist and be a directory.
83
+
- The request must have a `Atomic: yes` or `Atomic: no` header. Not every backend configuration makes it possible to perform atomic compare-and-swap operations; on backends without atomic CAS support, `Atomic: yes` requests will fail, while `Atomic: no` requests will provide a best-effort approximation.
84
+
- If a `PATCH` request loses a race against another content update request, it may return `409 Conflict`. This is true regardless of the `Atomic:` header value. Whenever this happens, resubmit the request as-is.
85
- If the site has no contents after the update is applied, performs the same action as `DELETE`.
86
* In response to a `DELETE` request, the server unpublishes a site. The URL of the request must be the root URL of the site that is being unpublished. Site data remains stored for an indeterminate period of time, but becomes completely inaccessible.
87
* If a `Dry-Run: yes` header is provided with a `PUT`, `PATCH`, `DELETE`, or `POST` request, only the authorization checks are run; no destructive updates are made. Note that this functionality was added in _git-pages_ v0.2.0.
+7
-7
src/pages.go
+7
-7
src/pages.go
···
537
// on the backend in use and its configuration, but for applications where a mostly-atomic
538
// compare-and-swap operation is good enough (e.g. generating page previews) we don't want
539
// to prevent the use of partial updates.
540
-
wantRaceFree := r.Header.Get("Race-Free")
541
hasAtomicCAS := backend.HasAtomicCAS(r.Context())
542
switch {
543
-
case wantRaceFree == "yes" && hasAtomicCAS || wantRaceFree == "no":
544
// all good
545
-
case wantRaceFree == "yes":
546
-
http.Error(w, "race free partial updates unsupported", http.StatusPreconditionFailed)
547
return nil
548
-
case wantRaceFree == "":
549
-
http.Error(w, "must provide \"Race-Free: yes|no\" header", http.StatusPreconditionRequired)
550
return nil
551
default:
552
-
http.Error(w, "malformed Race-Free: header", http.StatusBadRequest)
553
return nil
554
}
555
···
537
// on the backend in use and its configuration, but for applications where a mostly-atomic
538
// compare-and-swap operation is good enough (e.g. generating page previews) we don't want
539
// to prevent the use of partial updates.
540
+
wantAtomicCAS := r.Header.Get("Atomic")
541
hasAtomicCAS := backend.HasAtomicCAS(r.Context())
542
switch {
543
+
case wantAtomicCAS == "yes" && hasAtomicCAS || wantAtomicCAS == "no":
544
// all good
545
+
case wantAtomicCAS == "yes":
546
+
http.Error(w, "atomic partial updates unsupported", http.StatusPreconditionFailed)
547
return nil
548
+
case wantAtomicCAS == "":
549
+
http.Error(w, "must provide \"Atomic: yes|no\" header", http.StatusPreconditionRequired)
550
return nil
551
default:
552
+
http.Error(w, "malformed Atomic: header", http.StatusBadRequest)
553
return nil
554
}
555
+1
-1
test/stresspatch/main.go
+1
-1
test/stresspatch/main.go