mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
fix(gateway)!: no duplicate payload during subdomain redirects (#9913)
Co-authored-by: Marcin Rataj <lidel@lidel.org>
This commit is contained in:
parent
6eef0b4eef
commit
eb265f7cd8
@ -7,9 +7,10 @@
|
||||
- [Overview](#overview)
|
||||
- [🔦 Highlights](#-highlights)
|
||||
- [Saving previously seen nodes for later bootstrapping](#saving-previously-seen-nodes-for-later-bootstrapping)
|
||||
- [`Gateway.DeserializedResponses` config flag](#gatewaydeserializedresponses-config-flag)
|
||||
- [Gateway: `DeserializedResponses` config flag](#gateway-deserializedresponses-config-flag)
|
||||
- [`client/rpc` migration of `go-ipfs-http-client`](#clientrpc-migration-of-go-ipfs-http-client)
|
||||
- [Gateway: DAG-CBOR/-JSON previews and improved error pages](#gateway-dag-cbor-json-previews-and-improved-error-pages)
|
||||
- [Gateway: subdomain redirects are now `text/html`](#gateway-subdomain-redirects-are-now-texthtml)
|
||||
- [📝 Changelog](#-changelog)
|
||||
- [👨👩👧👦 Contributors](#-contributors)
|
||||
|
||||
@ -32,7 +33,7 @@ enabled.
|
||||
With this update, the same level of robustness is applied to peers that lack
|
||||
mDNS peers and solely rely on the public DHT.
|
||||
|
||||
#### `Gateway.DeserializedResponses` config flag
|
||||
#### Gateway: `DeserializedResponses` config flag
|
||||
|
||||
This release introduces the
|
||||
[`Gateway.DeserializedResponses`](https://github.com/ipfs/kubo/blob/master/docs/config.md#gatewaydeserializedresponses)
|
||||
@ -84,6 +85,23 @@ HTML responses are returned when request's `Accept` header includes `text/html`.
|
||||
| ---- | ---- |
|
||||
|  |  |
|
||||
|
||||
#### Gateway: subdomain redirects are now `text/html`
|
||||
|
||||
HTTP 301 redirects [from path to subdomain](https://specs.ipfs.tech/http-gateways/subdomain-gateway/#migrating-from-path-to-subdomain-gateway)
|
||||
no longer include the target data in the body.
|
||||
The data is returned only once, with the final HTTP 200 returned from the
|
||||
target subdomain.
|
||||
|
||||
The HTTP 301 body now includes human-readable `text/html` message
|
||||
for clients that do not follow redirects by default:
|
||||
|
||||
```console
|
||||
$ curl "https://subdomain-gw.example.net/ipfs/${cid}/"
|
||||
<a href="http://${cid}.ipfs.subdomain-gw.example.net/">Moved Permanently</a>.
|
||||
```
|
||||
|
||||
Rationale can be found in [kubo#9913](https://github.com/ipfs/kubo/pull/9913).
|
||||
|
||||
### 📝 Changelog
|
||||
|
||||
### 👨👩👧👦 Contributors
|
||||
|
||||
@ -7,7 +7,7 @@ go 1.18
|
||||
replace github.com/ipfs/kubo => ./../../..
|
||||
|
||||
require (
|
||||
github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076
|
||||
github.com/ipfs/boxo v0.8.2-0.20230602025754-4c5c98b94b21
|
||||
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
|
||||
github.com/libp2p/go-libp2p v0.27.3
|
||||
github.com/multiformats/go-multiaddr v0.9.0
|
||||
|
||||
@ -321,8 +321,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076 h1:jkmzkt/eRxC+tAOgUYOoQh50Bvfnun/Dy3n72tRSkmo=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076/go.mod h1:Ej2r08Z4VIaFKqY08UXMNhwcLf6VekHhK8c+KqA1B9Y=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230602025754-4c5c98b94b21 h1:efxZK66VVeQ1cGczX7ufjd4DW6X2nb/PbAJ5k85YC98=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230602025754-4c5c98b94b21/go.mod h1:Ej2r08Z4VIaFKqY08UXMNhwcLf6VekHhK8c+KqA1B9Y=
|
||||
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
|
||||
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
|
||||
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
|
||||
|
||||
2
go.mod
2
go.mod
@ -16,7 +16,7 @@ require (
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076
|
||||
github.com/ipfs/boxo v0.8.2-0.20230602025754-4c5c98b94b21
|
||||
github.com/ipfs/go-block-format v0.1.2
|
||||
github.com/ipfs/go-cid v0.4.1
|
||||
github.com/ipfs/go-cidutil v0.1.0
|
||||
|
||||
4
go.sum
4
go.sum
@ -356,8 +356,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076 h1:jkmzkt/eRxC+tAOgUYOoQh50Bvfnun/Dy3n72tRSkmo=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230531151409-d1b8d1d6d076/go.mod h1:Ej2r08Z4VIaFKqY08UXMNhwcLf6VekHhK8c+KqA1B9Y=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230602025754-4c5c98b94b21 h1:efxZK66VVeQ1cGczX7ufjd4DW6X2nb/PbAJ5k85YC98=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230602025754-4c5c98b94b21/go.mod h1:Ej2r08Z4VIaFKqY08UXMNhwcLf6VekHhK8c+KqA1B9Y=
|
||||
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
|
||||
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
|
||||
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
|
||||
|
||||
@ -162,14 +162,12 @@ test_localhost_gateway_response_should_contain \
|
||||
"http://localhost:$GWAY_PORT/ipfs/$DIR_CID/" \
|
||||
"Location: http://$DIR_CID.ipfs.localhost:$GWAY_PORT/"
|
||||
|
||||
# We return body with HTTP 301 so existing cli scripts that use path-based
|
||||
# gateway do not break (curl doesn't auto-redirect without passing -L; wget
|
||||
# does not span across hostnames by default)
|
||||
# Context: https://github.com/ipfs/go-ipfs/issues/6975
|
||||
# We return human-readable body with HTTP 301 so existing cli scripts that use path-based
|
||||
# gateway are informed to enable following HTTP redirects
|
||||
test_localhost_gateway_response_should_contain \
|
||||
"request for localhost/ipfs/{CIDv1} includes valid payload in body for CLI tools like curl" \
|
||||
"request for localhost/ipfs/{CIDv1} includes human-readable link and redirect info in HTTP 301 body" \
|
||||
"http://localhost:$GWAY_PORT/ipfs/$CIDv1" \
|
||||
"$CID_VAL"
|
||||
">Moved Permanently</a>"
|
||||
|
||||
test_localhost_gateway_response_should_contain \
|
||||
"request for localhost/ipfs/{CIDv0} redirects to CIDv1 representation in subdomain" \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user