@cryptotaxi247 / kubo / commits / 97527472f

feat(gateway): update gateway api, no multi-range support

Henrique Dias committed Oct 2, 2023 at 16:43 UTC 97527472fe4c037bb897aa2c7d4e0b2243b58f85
10 files changed +70 -17
CHANGELOG.md
+1
@@ -1,5 +1,6 @@
1 # Kubo Changelogs
2
3 +- [v0.24](docs/changelogs/v0.24.md)
4 - [v0.23](docs/changelogs/v0.23.md)
5 - [v0.22](docs/changelogs/v0.22.md)
6 - [v0.21](docs/changelogs/v0.21.md)
core/corehttp/gateway.go
+1 -1
@@ -167,7 +167,7 @@ func (o *offlineGatewayErrWrapper) GetBlock(ctx context.Context, path gateway.Im
167 return md, n, err
168 }
169
170 -func (o *offlineGatewayErrWrapper) Head(ctx context.Context, path gateway.ImmutablePath) (gateway.ContentPathMetadata, files.Node, error) {
170 +func (o *offlineGatewayErrWrapper) Head(ctx context.Context, path gateway.ImmutablePath) (gateway.ContentPathMetadata, *gateway.HeadResponse, error) {
171 md, n, err := o.gwimpl.Head(ctx, path)
172 err = offlineErrWrap(err)
173 return md, n, err
docs/changelogs/v0.24.md new
+27
@@ -0,0 +1,27 @@
1 +# Kubo changelog v0.24
2 +
3 +- [v0.24.0](#v0240)
4 +
5 +## v0.24.0
6 +
7 +- [Overview](#overview)
8 +- [🔦 Highlights](#-highlights)
9 + - [Gateway: the root of the CARs are no longer meaningful](#gateway-the-root-of-the-cars-are-no-longer-meaningful)
10 +- [📝 Changelog](#-changelog)
11 +- [👨‍👩‍👧‍👦 Contributors](#-contributors)
12 +
13 +### Overview
14 +
15 +### 🔦 Highlights
16 +
17 +#### Gateway: the root of the CARs are no longer meaningful
18 +
19 +When requesting a CAR from the gateway, the root of the CAR might no longer be
20 +meaningful. By default, the CAR root will be the last resolvable segment of the
21 +path. However, in situations where the path cannot be resolved, such as when
22 +the path does not exist, a CAR will be sent with a root of `bafkqaaa` (empty CID).
23 +This CAR will contain all blocks necessary to validate that the path does not exist.
24 +
25 +### 📝 Changelog
26 +
27 +### 👨‍👩‍👧‍👦 Contributors
docs/examples/kubo-as-a-library/go.mod
+1 -1
@@ -7,7 +7,7 @@ go 1.20
7 replace github.com/ipfs/kubo => ./../../..
8
9 require (
10 - github.com/ipfs/boxo v0.13.1
10 + github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0
11 github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
12 github.com/libp2p/go-libp2p v0.31.0
13 github.com/multiformats/go-multiaddr v0.11.0
docs/examples/kubo-as-a-library/go.sum
+2 -2
@@ -300,8 +300,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
300 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
301 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
302 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
303 -github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI=
304 -github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
303 +github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0 h1:oss04OCg1/QW0h3OfSCZJiUQErpYPOsz7+X4tpgwODs=
304 +github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
305 github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
306 github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
307 github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
go.mod
+1 -1
@@ -15,7 +15,7 @@ require (
15 github.com/fsnotify/fsnotify v1.6.0
16 github.com/google/uuid v1.3.0
17 github.com/hashicorp/go-multierror v1.1.1
18 - github.com/ipfs/boxo v0.13.1
18 + github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0
19 github.com/ipfs/go-block-format v0.1.2
20 github.com/ipfs/go-cid v0.4.1
21 github.com/ipfs/go-cidutil v0.1.0
go.sum
+2 -2
@@ -335,8 +335,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
335 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
336 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
337 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
338 -github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI=
339 -github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
338 +github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0 h1:oss04OCg1/QW0h3OfSCZJiUQErpYPOsz7+X4tpgwODs=
339 +github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
340 github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
341 github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
342 github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=
test/cli/gateway_range_test.go
+32 -7
@@ -41,7 +41,7 @@ func TestGatewayHAMTDirectory(t *testing.T) {
41 assert.Equal(t, http.StatusOK, resp.StatusCode)
42 }
43
44 -func TestGatewayMultiRange(t *testing.T) {
44 +func TestGatewayHAMTRanges(t *testing.T) {
45 t.Parallel()
46
47 const (
@@ -65,11 +65,36 @@ func TestGatewayMultiRange(t *testing.T) {
65 err = node.IPFSDagImport(r, fixtureCid)
66 assert.NoError(t, err)
67
68 - // Succeeds fetching a range of blocks we have
69 - resp := client.Get(fmt.Sprintf("/ipfs/%s", fileCid), func(r *http.Request) {
70 - r.Header.Set("Range", "bytes=1276-1279, 29839070-29839080")
68 + t.Run("Succeeds Fetching Range", func(t *testing.T) {
69 + t.Parallel()
70 +
71 + resp := client.Get(fmt.Sprintf("/ipfs/%s", fileCid), func(r *http.Request) {
72 + r.Header.Set("Range", "bytes=1276-1279")
73 + })
74 + assert.Equal(t, http.StatusPartialContent, resp.StatusCode)
75 + assert.Equal(t, "bytes 1276-1279/109266405", resp.Headers.Get("Content-Range"))
76 + assert.Equal(t, "iana", resp.Body)
77 + })
78 +
79 + t.Run("Succeeds Fetching Second Range", func(t *testing.T) {
80 + t.Parallel()
81 +
82 + resp := client.Get(fmt.Sprintf("/ipfs/%s", fileCid), func(r *http.Request) {
83 + r.Header.Set("Range", "bytes=29839070-29839080")
84 + })
85 + assert.Equal(t, http.StatusPartialContent, resp.StatusCode)
86 + assert.Equal(t, "bytes 29839070-29839080/109266405", resp.Headers.Get("Content-Range"))
87 + assert.Equal(t, "EXAMPLE.COM", resp.Body)
88 + })
89 +
90 + t.Run("Succeeds Fetching First Range of Multi-range Request", func(t *testing.T) {
91 + t.Parallel()
92 +
93 + resp := client.Get(fmt.Sprintf("/ipfs/%s", fileCid), func(r *http.Request) {
94 + r.Header.Set("Range", "bytes=1276-1279, 29839070-29839080")
95 + })
96 + assert.Equal(t, http.StatusPartialContent, resp.StatusCode)
97 + assert.Equal(t, "bytes 1276-1279/109266405", resp.Headers.Get("Content-Range"))
98 + assert.Equal(t, "iana", resp.Body)
99 })
72 - assert.Equal(t, http.StatusPartialContent, resp.StatusCode)
73 - assert.Contains(t, resp.Body, "Content-Range: bytes 1276-1279/109266405\r\nContent-Type: text/plain; charset=utf-8\r\n\r\niana\r\n")
74 - assert.Contains(t, resp.Body, "Content-Range: bytes 29839070-29839080/109266405\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nEXAMPLE.COM\r\n")
100 }
test/dependencies/go.mod
+1 -1
@@ -7,7 +7,7 @@ replace github.com/ipfs/kubo => ../../
7 require (
8 github.com/Kubuxu/gocovmerge v0.0.0-20161216165753-7ecaa51963cd
9 github.com/golangci/golangci-lint v1.54.1
10 - github.com/ipfs/boxo v0.13.1
10 + github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0
11 github.com/ipfs/go-cid v0.4.1
12 github.com/ipfs/go-cidutil v0.1.0
13 github.com/ipfs/go-datastore v0.6.0
test/dependencies/go.sum
+2 -2
@@ -396,8 +396,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
396 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
397 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
398 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
399 -github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI=
400 -github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
399 +github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0 h1:oss04OCg1/QW0h3OfSCZJiUQErpYPOsz7+X4tpgwODs=
400 +github.com/ipfs/boxo v0.13.2-0.20231002142647-c28c847582f0/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
401 github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
402 github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
403 github.com/ipfs/go-block-format v0.1.2 h1:GAjkfhVx1f4YTODS6Esrj1wt2HhrtwTnhEr+DyPUaJo=