Skip to content

Commit

Permalink
add comma spacing for content-encoding header
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Oct 1, 2024
1 parent 3168eda commit 29e2c92
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe(compressionMiddleware.name, () => {
body: mockCompressedBody,
headers: {
...mockArgs.request.headers,
"content-encoding": [mockExistingContentEncoding, "gzip"].join(","),
"content-encoding": [mockExistingContentEncoding, "gzip"].join(", "),
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const compressionMiddleware =
if (headers["content-encoding"]) {
updatedHeaders = {
...headers,
"content-encoding": `${headers["content-encoding"]},${algorithm}`,
"content-encoding": `${headers["content-encoding"]}, ${algorithm}`,
};
} else {
updatedHeaders = { ...headers, "content-encoding": algorithm };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ public final class HttpProtocolTestGenerator implements Runnable {

private static final Logger LOGGER = Logger.getLogger(HttpProtocolTestGenerator.class.getName());
private static final String TEST_CASE_FILE_TEMPLATE = "test/functional/%s.spec.ts";
private static final Set<String> IGNORE_COMMA_SPACING = SetUtils.of(
"content-encoding"
);

private final TypeScriptSettings settings;
private final Model model;
Expand Down Expand Up @@ -521,17 +518,7 @@ private void writeHttpHeaderAssertions(HttpMessageTestCase testCase) {
testCase.getHeaders().forEach((header, value) -> {
header = header.toLowerCase();
writer.write("expect(r.headers[$S]).toBeDefined();", header);
if (IGNORE_COMMA_SPACING.contains(header) && value.contains(",")) {
writer.write("""
expect(
r.headers[$S].replaceAll(", ", ",")
).toBe(
$S.replaceAll(", ", ",")
);
""", header, value);
} else {
writer.write("expect(r.headers[$S]).toBe($S);", header, value);
}
writer.write("expect(r.headers[$S]).toBe($S);", header, value);
});
writer.write("");
}
Expand Down

0 comments on commit 29e2c92

Please sign in to comment.