oxy-server: after_push receives the request headers, so a host can attribute the push 76f752503e7e
- Author
- Andy McCall @andymccall <[email protected]>
- When
- · 2026-09-27 18:16 UTC
- Signature
- ✔ signed by Andy McCall
- Hash
76f752503e7e4d6e0aa07f080a8a8b8cd480292c93094c73b5b2b6df997ff7c8- Depends on
- 05e71ed6cdf1 750251b21a96 75167672ebcd 7aa2dc9369e3 e02bf0cd0533
- Depended on by
- be451356e3ef f8c695764c95 be0161a88dd7
- In bookmarks
- agents-in-readme bare-hashes carried-not-removed carry-identical doctor-trust identical-sides keyless-tags main merge-remote-bookmark only-help-103 paths-for-resolutions-and-amend push-notes show-stat subrepo-pin-state switch-says
- In tags
- v0.1.0 v0.10.0 v0.11.0 v0.2.0 v0.3.0 v0.3.1 v0.4.0 v0.4.1 v0.4.2 v0.4.3 v0.4.4 v0.4.5 v0.4.6 v0.5.0 v0.5.1 v0.6.0 v0.7.0 v0.8.0 v0.9.0
- Edits
- 8 atoms, 0 tree operations, 2 files
Browse the tree at this change
modified crates/oxy-server/src/lib.rs +5 −3
| … | 61 unchanged lines |
||
| 62 | 62 | /// Called after a push was processed, with its per-reference results |
|
| 63 | 63 | /// (accepted or refused), the states each accepted reference moved |
|
| 64 | 64 | /// between, and the changes stored, for logs and cache invalidation. |
|
| 65 | - | fn after_push(&self, _name: &str, _report: &oxy_core::repo::PushReport) {} |
|
| 65 | + | fn after_push(&self, _name: &str, _report: &oxy_core::repo::PushReport, _headers: &HeaderMap) {} |
|
| 66 | 66 | } |
|
| 67 | 67 | ||
| 68 | 68 | /// A protocol server over any [`Backend`], serialising the pushes to each |
|
| … | 134 unchanged lines |
||
| 203 | 203 | .and_then(|v| v.to_str().ok()) |
|
| 204 | 204 | .and_then(hex_id); |
|
| 205 | 205 | let server = Arc::clone(self); |
|
| 206 | + | let request_headers = headers.clone(); |
|
| 206 | 207 | let result = |
|
| 207 | - | tokio::task::spawn_blocking(move || server.respond(&name, endpoint, body, claimed)) |
|
| 208 | + | tokio::task::spawn_blocking(move || server.respond(&name, endpoint, body, claimed, &request_headers)) |
|
| 208 | 209 | .await; |
|
| 209 | 210 | match result { |
|
| 210 | 211 | Ok(Ok(r)) => r, |
|
| … | 8 unchanged lines |
||
| 219 | 220 | endpoint: Endpoint, |
|
| 220 | 221 | body: Bytes, |
|
| 221 | 222 | claimed: Option<[u8; 16]>, |
|
| 223 | + | headers: &HeaderMap, |
|
| 222 | 224 | ) -> Result<Response, Failure> { |
|
| 223 | 225 | let r = self.backend.open(name)?; |
|
| 224 | 226 | Ok(match endpoint { |
|
| … | 47 unchanged lines |
||
| 272 | 274 | } |
|
| 273 | 275 | } |
|
| 274 | 276 | let report = r.receive_push_report(bundle, updates, policy, tags)?; |
|
| 275 | - | self.backend.after_push(name, &report); |
|
| 277 | + | self.backend.after_push(name, &report, headers); |
|
| 276 | 278 | ok(wire::encode_push_response(&report.results)) |
|
| 277 | 279 | } |
|
| 278 | 280 | }) |
|
| … | 110 unchanged lines |
modified crates/oxy-server/tests/http.rs +1 −1
| … | 391 unchanged lines |
||
| 392 | 392 | } |
|
| 393 | 393 | Ok(()) |
|
| 394 | 394 | } |
|
| 395 | - | fn after_push(&self, name: &str, report: &oxy_core::repo::PushReport) { |
|
| 395 | + | fn after_push(&self, name: &str, report: &oxy_core::repo::PushReport, _headers: &HeaderMap) { |
|
| 396 | 396 | self.pushes.lock().unwrap().push(format!( |
|
| 397 | 397 | "{name}: {} ok, {} updated to {} head(s), {} imported", |
|
| 398 | 398 | report.results.iter().filter(|r| r.ok).count(), |
|
| … | 188 unchanged lines |