Skip to content

Voeg Quarkus voorbeeld toe - #1

Open
TimvdLippe wants to merge 10 commits into
developfrom
quarkus-example
Open

Voeg Quarkus voorbeeld toe#1
TimvdLippe wants to merge 10 commits into
developfrom
quarkus-example

Conversation

@TimvdLippe

Copy link
Copy Markdown

No description provided.

@github-actions

Copy link
Copy Markdown

@TimvdLippe
TimvdLippe requested a review from sanderke August 19, 2026 12:37
@TimvdLippe
TimvdLippe marked this pull request as ready for review August 19, 2026 12:37
@TimvdLippe

Copy link
Copy Markdown
Author

Tests in examples/quarkus/src/test/java/org/acme/ServerToClientResourceTest.java laten zien dat alle headers correct worden gezet

int endIndex = rangeHeaderIndices.endIndex();

var totalFileSize = fullFileContent.length();
if (startIndex > totalFileSize || endIndex > totalFileSize) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (startIndex > totalFileSize || endIndex > totalFileSize) {
if (startIndex >= totalFileSize) {

Mocht je enkel de laatste byte willen, dan zijn ze gelijk. En endIndex te groot mag ook:

If the last-pos value is absent, or if the value is greater than or equal to the current length of the representation data, the byte range is interpreted as the remainder of the representation (i.e., the server replaces the value of last-pos with a value that is one less than the current length of the selected representation).

.withDetail("End index should be larger than start")
.build();
}
return new RangeHeaderIndices(startIndex, endIndex);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return new RangeHeaderIndices(startIndex, endIndex);
return new RangeHeaderIndices(startIndex, endIndex+1);

Of totalFileSize als eindpunt, als dat eerder komt.

Comment on lines +169 to +174
assert.equal(headers.get("Content-Digest"), "sha-256=:4BVa2bszMXotZewPuxyxoNDP/ZAnBgNgdTRYjWn2uhY=:");
assert.equal(headers.get("Content-Range"), "bytes 10-12/35");
assert.equal(headers.get("ETag"), ETAG_FOR_FILE);
assert.equal(headers.get("Repr-Digest"), REPR_DIGEST_FOR_FILE);
assert.equal(fileResponse.status, 206);
assert.equal(await fileResponse.text(), "fil");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
assert.equal(headers.get("Content-Digest"), "sha-256=:4BVa2bszMXotZewPuxyxoNDP/ZAnBgNgdTRYjWn2uhY=:");
assert.equal(headers.get("Content-Range"), "bytes 10-12/35");
assert.equal(headers.get("ETag"), ETAG_FOR_FILE);
assert.equal(headers.get("Repr-Digest"), REPR_DIGEST_FOR_FILE);
assert.equal(fileResponse.status, 206);
assert.equal(await fileResponse.text(), "fil");
assert.equal(headers.get("Content-Digest"), "sha-256=:O5w1jzbwoxtq0+FPMJx88ZiskkboMW+c5UPVsZrAK4A=:");
assert.equal(headers.get("Content-Range"), "bytes 10-13/35");
assert.equal(headers.get("ETag"), ETAG_FOR_FILE);
assert.equal(headers.get("Repr-Digest"), REPR_DIGEST_FOR_FILE);
assert.equal(fileResponse.status, 206);
assert.equal(await fileResponse.text(), "file");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah, zero-indexed & inclusive. Ja klopt

Comment on lines +203 to +208
assert.equal(headers.get("Content-Digest"), "sha-256=:4BVa2bszMXotZewPuxyxoNDP/ZAnBgNgdTRYjWn2uhY=:");
assert.equal(headers.get("Content-Range"), "bytes 10-12/35");
assert.equal(headers.get("ETag"), ETAG_FOR_FILE);
assert.equal(headers.get("Repr-Digest"), REPR_DIGEST_FOR_FILE);
assert.equal(fileResponse.status, 206);
assert.equal(await fileResponse.text(), "fil");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
assert.equal(headers.get("Content-Digest"), "sha-256=:4BVa2bszMXotZewPuxyxoNDP/ZAnBgNgdTRYjWn2uhY=:");
assert.equal(headers.get("Content-Range"), "bytes 10-12/35");
assert.equal(headers.get("ETag"), ETAG_FOR_FILE);
assert.equal(headers.get("Repr-Digest"), REPR_DIGEST_FOR_FILE);
assert.equal(fileResponse.status, 206);
assert.equal(await fileResponse.text(), "fil");
assert.equal(headers.get("Content-Digest"), "sha-256=:O5w1jzbwoxtq0+FPMJx88ZiskkboMW+c5UPVsZrAK4A=:");
assert.equal(headers.get("Content-Range"), "bytes 10-13/35");
assert.equal(headers.get("ETag"), ETAG_FOR_FILE);
assert.equal(headers.get("Repr-Digest"), REPR_DIGEST_FOR_FILE);
assert.equal(fileResponse.status, 206);
assert.equal(await fileResponse.text(), "file");

Comment on lines +174 to +185
void testNegativeRangeTooLargeResultsInBadRequest() {
given().header("Range", "bytes=-130")
.when()
.get(LARGE_FILE_CONTENT_LOCATION)
.then()
.statusCode(416)
.contentType("application/problem+json")
.body("status", Matchers.equalTo(416))
.body("title", Matchers.equalTo("Invalid range header content"))
.body("detail", Matchers.equalTo("Negative range larger than file content"))
.body("instance", Matchers.equalTo(LARGE_FILE_CONTENT_LOCATION));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the selected representation is shorter than the specified suffix-length, the entire representation is used.

assert.equal(fileContent, LARGE_FILE_CONTENT);
});

describe("rejects retrieval with range", () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A server MUST ignore a Range header field received with a request method that is unrecognized or for which range handling is not defined.

Dus deze gevallen zouden dan 200 zijn met het hele bestand?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ik interpreteerde die zin als "als je een Range doet met een POST, negeer die dan". Sowieso ben ik ook niet happy met de 200 hier heb je het hele bestand. Dat vind ik ook tegen intuitief voor een module die grote berichten in stukken wil verdelen.

Daarom zou ik dit strikt houden en 400 terug geven. Wat denk jij?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, die ging over de method, maar de zin daarna lijkt wel echt over een voor de server onbegrijpelijke Range header field zelf te gaan:

An origin server MUST ignore a Range header field that contains a range unit it does not understand.

void testRangeDoesNotStartWithBytesResultsInBadRequest() {
given().header("Range", "string=10-13")

Een bij de server (nog) niet geimplementeerde eenheid is nog niet meteen een client error, dus dan maar wel 200 "ik weet niet welk deel je wilt, dus hier is alles" (graceful?). De andere cases zijn zonder twijfel fout en dus inderdaad beter 400.

@TimvdLippe TimvdLippe left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks voor de review! Ik zal die punten verwerken. 1 comment met de interpretatie van die zin

assert.equal(fileContent, LARGE_FILE_CONTENT);
});

describe("rejects retrieval with range", () => {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ik interpreteerde die zin als "als je een Range doet met een POST, negeer die dan". Sowieso ben ik ook niet happy met de 200 hier heb je het hele bestand. Dat vind ik ook tegen intuitief voor een module die grote berichten in stukken wil verdelen.

Daarom zou ik dit strikt houden en 400 terug geven. Wat denk jij?

Comment on lines +169 to +174
assert.equal(headers.get("Content-Digest"), "sha-256=:4BVa2bszMXotZewPuxyxoNDP/ZAnBgNgdTRYjWn2uhY=:");
assert.equal(headers.get("Content-Range"), "bytes 10-12/35");
assert.equal(headers.get("ETag"), ETAG_FOR_FILE);
assert.equal(headers.get("Repr-Digest"), REPR_DIGEST_FOR_FILE);
assert.equal(fileResponse.status, 206);
assert.equal(await fileResponse.text(), "fil");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah, zero-indexed & inclusive. Ja klopt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants