Skip to content

Commit

Permalink
chore: update to go-trustless-utils@0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Sep 7, 2023
1 parent 8fcb750 commit 1e41cf4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ require (
github.com/ipfs/go-ipld-format v0.6.0
github.com/ipfs/go-log/v2 v2.5.1
github.com/ipfs/go-unixfsnode v1.8.0
github.com/ipld/go-car/v2 v2.13.0
github.com/ipld/go-car/v2 v2.13.1
github.com/ipld/go-ipld-prime v0.21.0
github.com/ipld/go-trustless-utils v0.0.0
github.com/ipld/ipld/specs v0.0.0-20230826120441-91918996e8eb
github.com/ipld/go-trustless-utils v0.1.1-0.20230907052210-888f5a90eebb
github.com/ipld/ipld/specs v0.0.0-20230907004443-0e4ff95ff474
github.com/ipni/go-libipni v0.3.4
github.com/ipni/index-provider v0.13.5
github.com/libp2p/go-libp2p v0.30.0
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,19 @@ github.com/ipfs/go-unixfs v0.4.4 h1:D/dLBOJgny5ZLIur2vIXVQVW0EyDHdOMBDEhgHrt6rY=
github.com/ipfs/go-unixfsnode v1.8.0 h1:yCkakzuE365glu+YkgzZt6p38CSVEBPgngL9ZkfnyQU=
github.com/ipfs/go-unixfsnode v1.8.0/go.mod h1:HxRu9HYHOjK6HUqFBAi++7DVoWAHn0o4v/nZ/VA+0g8=
github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvTs=
github.com/ipld/go-car/v2 v2.13.0 h1:ogsB0rm6cclI2/HxP2XM+z+KehNj2ovpz0YfiF1hJwE=
github.com/ipld/go-car/v2 v2.13.0/go.mod h1:QkdjjFNGit2GIkpQ953KBwowuoukoM75nP/JI1iDJdo=
github.com/ipld/go-car/v2 v2.13.1 h1:KnlrKvEPEzr5IZHKTXLAEub+tPrzeAFQVRlSQvuxBO4=
github.com/ipld/go-car/v2 v2.13.1/go.mod h1:QkdjjFNGit2GIkpQ953KBwowuoukoM75nP/JI1iDJdo=
github.com/ipld/go-codec-dagpb v1.6.0 h1:9nYazfyu9B1p3NAgfVdpRco3Fs2nFC72DqVsMj6rOcc=
github.com/ipld/go-codec-dagpb v1.6.0/go.mod h1:ANzFhfP2uMJxRBr8CE+WQWs5UsNa0pYtmKZ+agnUw9s=
github.com/ipld/go-ipld-adl-hamt v0.0.0-20220616142416-9004dbd839e0 h1:QAI/Ridj0+foHD6epbxmB4ugxz9B4vmNdYSmQLGa05E=
github.com/ipld/go-ipld-adl-hamt v0.0.0-20220616142416-9004dbd839e0/go.mod h1:odxGcpiQZLzP5+yGu84Ljo8y3EzCvNAQKEodHNsHLXA=
github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E=
github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ=
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20230102063945-1a409dc236dd h1:gMlw/MhNr2Wtp5RwGdsW23cs+yCuj9k2ON7i9MiJlRo=
github.com/ipld/go-trustless-utils v0.0.0 h1:X+hY7lWZSd6kdBGfmGtEIjCUeqETaeahMKjont7+OGo=
github.com/ipld/go-trustless-utils v0.0.0/go.mod h1:rqvDGdgk2acsKiGyV5mzCZZRK8JtnEZqvUBxLuYxR6A=
github.com/ipld/ipld/specs v0.0.0-20230826120441-91918996e8eb h1:5ARxkQ9NqZq33RM7i/Eq3bvBj2RBxx2xE63hqfa+9KY=
github.com/ipld/ipld/specs v0.0.0-20230826120441-91918996e8eb/go.mod h1:AfGlAr20WOjV5PyCowEnGY3pAm5x5i+o0R8IUeir6cs=
github.com/ipld/go-trustless-utils v0.1.1-0.20230907052210-888f5a90eebb h1:/2SrCiC6LPchG3Ll/Cm0EiEy/+iumuo77PBP4uHhXwQ=
github.com/ipld/go-trustless-utils v0.1.1-0.20230907052210-888f5a90eebb/go.mod h1:nbUA6YuKZqNHYd3mYKALxOQa5aC8fnr2w+OxirSSOqc=
github.com/ipld/ipld/specs v0.0.0-20230907004443-0e4ff95ff474 h1:CiDtcUFyzRwhKyiS4Gn+fzdraMoNVtPHd+wVIekExPc=
github.com/ipld/ipld/specs v0.0.0-20230907004443-0e4ff95ff474/go.mod h1:WcT0DfRe+e2QFY0kcbsOnuT6jL5Q0JNZ83I5DHIdStg=
github.com/ipni/go-libipni v0.3.4 h1:ZYgCE2TOZt/QJJcBZb+R63FaBLlA2suZGP2IH1fKv4A=
github.com/ipni/go-libipni v0.3.4/go.mod h1:6EIUhN83pd1i6q7SCSCIuuUC3XgR7D/gjKkEnVyIQWE=
github.com/ipni/index-provider v0.13.5 h1:pNOO795k4mR0bwm9npkapSWJld7fYP/8//DMJZi1w/M=
Expand Down
6 changes: 3 additions & 3 deletions httpipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (hi *HttpIpfs) ServeHTTP(res http.ResponseWriter, req *http.Request) {
return
}

includeDupes, err := trustlesshttp.CheckFormat(req)
accept, err := trustlesshttp.CheckFormat(req)
if err != nil {
logError(http.StatusBadRequest, err)
return
Expand Down Expand Up @@ -154,7 +154,7 @@ func (hi *HttpIpfs) ServeHTTP(res http.ResponseWriter, req *http.Request) {
Path: path.String(),
Scope: dagScope,
Bytes: byteRange,
Duplicates: includeDupes,
Duplicates: accept.Duplicates,
}

if fileName == "" {
Expand All @@ -166,7 +166,7 @@ func (hi *HttpIpfs) ServeHTTP(res http.ResponseWriter, req *http.Request) {
// called once we start writing blocks into the CAR (on the first Put())
res.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%q", fileName))
res.Header().Set("Cache-Control", trustlesshttp.ResponseCacheControlHeader)
res.Header().Set("Content-Type", trustlesshttp.ResponseContentTypeHeader(includeDupes))
res.Header().Set("Content-Type", accept.String())
res.Header().Set("Etag", request.Etag())
res.Header().Set("X-Content-Type-Options", "nosniff")
res.Header().Set("X-Ipfs-Path", "/"+datamodel.ParsePath(req.URL.Path).String())
Expand Down
14 changes: 7 additions & 7 deletions httpipfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ func TestHttpIpfsHandler(t *testing.T) {
{
name: "bad cid",
path: "/ipfs/foobarbaz",
accept: trustlesshttp.RequestAcceptHeader(true),
accept: trustlesshttp.NewContentType().String(),
expectedStatusCode: http.StatusBadRequest,
expectedBody: "failed to parse CID path parameter",
},
{
name: "bad dag-scope",
path: "/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi?dag-scope=bork",
accept: trustlesshttp.RequestAcceptHeader(true),
accept: trustlesshttp.NewContentType().String(),
expectedStatusCode: http.StatusBadRequest,
expectedBody: "invalid dag-scope parameter",
},
{
name: "bad entity-bytes",
path: "/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi?entity-bytes=bork",
accept: trustlesshttp.RequestAcceptHeader(true),
accept: trustlesshttp.NewContentType().String(),
expectedStatusCode: http.StatusBadRequest,
expectedBody: "invalid entity-bytes parameter",
},
Expand All @@ -73,7 +73,7 @@ func TestHttpIpfsHandler(t *testing.T) {
// at least loaded the first block.
name: "block not found",
path: "/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
accept: trustlesshttp.RequestAcceptHeader(true),
accept: trustlesshttp.NewContentType().String(),
expectedStatusCode: http.StatusInternalServerError,
expectedBody: "failed to load root node: failed to load root CID: ipld: could not find bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
},
Expand All @@ -98,7 +98,7 @@ func TestHttpIpfsHandler(t *testing.T) {
func TestIntegration_Unixfs20mVariety(t *testing.T) {
req := require.New(t)

testCases, err := trustlesspathing.Unixfs20mVarietyCases()
testCases, _, err := trustlesspathing.Unixfs20mVarietyCases()
req.NoError(err)
storage, closer, err := trustlesspathing.Unixfs20mVarietyReadableStorage()
req.NoError(err)
Expand All @@ -121,11 +121,11 @@ func TestIntegration_Unixfs20mVariety(t *testing.T) {

request, err := http.NewRequest(http.MethodGet, testServer.URL+tc.AsQuery(), nil)
req.NoError(err)
request.Header.Set("Accept", trustlesshttp.RequestAcceptHeader(false))
request.Header.Set("Accept", trustlesshttp.NewContentType(trustlesshttp.WithContentTypeDuplicates(false)).String())
res, err := http.DefaultClient.Do(request)
req.NoError(err)
req.Equal(http.StatusOK, res.StatusCode)
req.Equal(trustlesshttp.ResponseContentTypeHeader(false), res.Header.Get("Content-Type"))
req.Equal(trustlesshttp.NewContentType(trustlesshttp.WithContentTypeDuplicates(false)).String(), res.Header.Get("Content-Type"))

carReader, err := car.NewBlockReader(res.Body)
req.NoError(err)
Expand Down

0 comments on commit 1e41cf4

Please sign in to comment.