Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: http range with file-3k-and-3-blocks-missing-block.car #213

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
34 changes: 34 additions & 0 deletions tests/path_gateway_unixfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ func TestGatewayUnixFSFileRanges(t *testing.T) {

tests := SugarTests{}

// Wer use contentType from the smoke-test above to determine which
// range tests should be executed.
// TODO: move range requests to own 'spec' so they can be enabled/disabled
// similar to proxy-gateway feature
if strings.Contains(contentType, "text/plain") {
// The server is not able to respond to a multi-range request. Therefore,
// there might be only one range or... just the whole file, depending on the headers.
Expand Down Expand Up @@ -591,6 +595,36 @@ func TestGatewayUnixFSFileRanges(t *testing.T) {
t.Error("Content-Type header did not match any of the accepted options")
}

// If gateway supports Range requests
// Run the Range rest against the file-3k-and-3-blocks-missing-block.car
// special fixture from ?format=car&entity-bytes test.
if contentRange != "" || strings.Contains(contentType, "multipart/byteranges") {
missingBlockFixture := car.MustOpenUnixfsCar("trustless_gateway_car/file-3k-and-3-blocks-missing-block.car")

tests = append(tests, SugarTest{
Name: "GET Range of file succeeds even if the gateway is missing a block after the requested range",
Hint: "This MUST succeed despite the fact that bytes beyond the end of range are not retrievable",
Request: Request().
Path("/ipfs/{{cid}}", missingBlockFixture.MustGetCidWithCodec(0x70)).
Headers(
Header("Range", "bytes=0-1000"),
),
Response: Expect().
Status(206).
Headers(
// TODO: fix HTTP 500: cannot detect content-type: failed to fetch all nodes i boxo/gateway (or create better fixture that does not clash with content-type sniffing logic)
Header("Content-Type").Contains("text/plain"),
Header("Content-Range").Equals("bytes 0-1000/31"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 switch to size form unixfs, once HTTP 500 is resolved

),
// TODO: we are missing helper for returning byte range from a
// CAR. the fixture here is multi-block, and we can use
// missingBlockFixture.MustGetRawData because raw data spans
// across more than one block.
},
// TODO: port test fror range AFTER missing block as well
)
}

RunWithSpecs(t, tests, specs.PathGatewayUnixFS)
}

Expand Down
Loading