Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .changeset/conformance-same-origin-redirects.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"@thomasfosterau/effect-jsonapi": patch
---

`Conformance` now follows a redirect when, and only when, its `Location` stays on the base URL's origin (scheme, host and port), in both transports. Previously every `3xx` answered a probe as itself. The kit checks each hop before requesting it, so it never sends a request to another origin on a server's say-so. It follows at most five hops for one request, each counting against a rule's request budget, and grades the final answer. A `301`, `302` or `303` is followed only for a `GET`; a `307` or `308` re-sends the same method and body. A `3xx` with no `Location`, or an empty one, answers as itself.
`Conformance` now follows a redirect when, and only when, its `Location` stays on the base URL's origin (scheme, host and port), in both transports. Previously every `3xx` answered a probe as itself. The kit checks each hop before requesting it, so, unless the client it is given follows redirects itself, it never sends a request to another origin on a server's say-so. It follows at most five hops for one request, each counting against a rule's request budget, and grades the final answer. A `301`, `302` or `303` is followed only for a `GET`; a `307` or `308` re-sends the same method and body. A `3xx` with no `Location`, or an empty one, answers as itself.

A redirect the kit does not follow leaves the request with no answer to read: one to another origin, past the hop cap or the budget, one that would turn a write into a `GET`, or one whose `Location` does not parse. An `http` → `https` redirect on the same host counts as another origin. A rule that sent such a request — a probe, or a read endpoint, link or page the link rules and the pagination walk fetch — drops a finding the request produced, so it never reports a probe that went unanswered as "not rejected"; a finding on an answer it did read still fails the rule. Otherwise the rule is `Skipped`, naming the redirects (the first three by their `Location`, the rest counted) and keeping its own note; a rule that skipped on its own names them after its reason. No rule is passed on the answers it did read alone. `spec/target/reachable` reports such a redirect once instead, as one finding telling the caller to point `baseUrl` at the URL that serves.
A redirect the kit does not follow leaves the request with no answer to read: one to another origin, past the hop cap or the budget, one that would turn a write into a `GET`, or one whose `Location` does not parse. So does one a transport followed on its own (one wrapped in `HttpClient.followRedirects`, say) to another origin, or turning the method into a `GET`: the kit reads neither the answer nor the transport error it ended in, and names the URL the transport ended at. Only that final URL and method are checked, so a chain the transport followed off the origin and back, keeping the method, goes undetected. An `http` → `https` redirect on the same host counts as another origin. A rule that sent such a request — a probe, or a read endpoint, link or page the link rules and the pagination walk fetch — drops a finding the request produced, so it never reports a probe that went unanswered as "not rejected"; a finding on an answer it did read still fails the rule. Otherwise the rule is `Skipped`, naming the redirects (the first three by their request and `Location`, the rest counted) and keeping its own note; a rule that skipped on its own names them after its reason. No rule is passed on the answers it did read alone. `spec/target/reachable` reports such a redirect once instead, as one finding telling the caller what to change: point `baseUrl` at the URL that serves, shorten a chain on the base URL's origin longer than the hop cap, fix a `Location` that does not parse, or pass a client that does not follow redirects itself. A rule probing a query parameter an endpoint does not declare names such a redirect without calling it a lost response.

`spec/links/related-dereferences` now requires each resource object in the answer to carry a string `type`, so `{"data":"x"}`, `{"data":["x"]}` and `{"data":[{"id":"1"}]}` are findings. The link rules' budget skip no longer counts a read endpoint whose URL does not resolve as searched. A write rule that could not read the create's answer now names it, rather than a bare `0`.

Expand Down
Loading
Loading