Rename PATCH Race-Free: header to Atomic:.

Neither of these names is self-explanatory, and it is better to have
fewer distinct identifiers for the same concept.
This commit is contained in:
Catherine
2025-12-04 16:51:32 +00:00
parent 1c017020c1
commit f59830ae20
3 changed files with 10 additions and 10 deletions
+2 -2
View File
@@ -80,8 +80,8 @@ Features
- A directory entry replaces any existing file or directory with the same name (if any), recursively removing the old contents. - A directory entry replaces any existing file or directory with the same name (if any), recursively removing the old contents.
- A file or symlink entry replaces any existing file or directory with the same name (if any). - A file or symlink entry replaces any existing file or directory with the same name (if any).
- In any case, the parent of an entry must exist and be a directory. - In any case, the parent of an entry must exist and be a directory.
- 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. - 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.
- 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. - 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.
- If the site has no contents after the update is applied, performs the same action as `DELETE`. - If the site has no contents after the update is applied, performs the same action as `DELETE`.
* 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. * 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.
* 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. * 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
View File
@@ -537,19 +537,19 @@ func patchPage(w http.ResponseWriter, r *http.Request) error {
// on the backend in use and its configuration, but for applications where a mostly-atomic // on the backend in use and its configuration, but for applications where a mostly-atomic
// compare-and-swap operation is good enough (e.g. generating page previews) we don't want // compare-and-swap operation is good enough (e.g. generating page previews) we don't want
// to prevent the use of partial updates. // to prevent the use of partial updates.
wantRaceFree := r.Header.Get("Race-Free") wantAtomicCAS := r.Header.Get("Atomic")
hasAtomicCAS := backend.HasAtomicCAS(r.Context()) hasAtomicCAS := backend.HasAtomicCAS(r.Context())
switch { switch {
case wantRaceFree == "yes" && hasAtomicCAS || wantRaceFree == "no": case wantAtomicCAS == "yes" && hasAtomicCAS || wantAtomicCAS == "no":
// all good // all good
case wantRaceFree == "yes": case wantAtomicCAS == "yes":
http.Error(w, "race free partial updates unsupported", http.StatusPreconditionFailed) http.Error(w, "atomic partial updates unsupported", http.StatusPreconditionFailed)
return nil return nil
case wantRaceFree == "": case wantAtomicCAS == "":
http.Error(w, "must provide \"Race-Free: yes|no\" header", http.StatusPreconditionRequired) http.Error(w, "must provide \"Atomic: yes|no\" header", http.StatusPreconditionRequired)
return nil return nil
default: default:
http.Error(w, "malformed Race-Free: header", http.StatusBadRequest) http.Error(w, "malformed Atomic: header", http.StatusBadRequest)
return nil return nil
} }
+1 -1
View File
@@ -57,7 +57,7 @@ func patchRequest(n int) int {
panic(err) panic(err)
} }
req.Header.Add("Race-Free", "no") req.Header.Add("Atomic", "no")
req.Header.Add("Content-Type", "application/x-tar") req.Header.Add("Content-Type", "application/x-tar")
resp, err := http.DefaultClient.Do(req) resp, err := http.DefaultClient.Do(req)
if err != nil { if err != nil {