diff --git a/src/client/testing/testController/common/utils.ts b/src/client/testing/testController/common/utils.ts index 1272ff37fb5d..aa95c08a3a0c 100644 --- a/src/client/testing/testController/common/utils.ts +++ b/src/client/testing/testController/common/utils.ts @@ -114,8 +114,10 @@ export function parseJsonRPCHeadersAndData(rawData: string): ParsedRPCHeadersAnd break; } const [key, value] = line.split(':'); - if ([JSONRPC_UUID_HEADER, JSONRPC_CONTENT_LENGTH_HEADER, JSONRPC_CONTENT_TYPE_HEADER].includes(key)) { - headerMap.set(key.trim(), value.trim()); + if (value.trim()) { + if ([JSONRPC_UUID_HEADER, JSONRPC_CONTENT_LENGTH_HEADER, JSONRPC_CONTENT_TYPE_HEADER].includes(key)) { + headerMap.set(key.trim(), value.trim()); + } } } diff --git a/src/test/testing/common/testingPayloadsEot.test.ts b/src/test/testing/common/testingPayloadsEot.test.ts index 9025248c66ff..a30b1efe288c 100644 --- a/src/test/testing/common/testingPayloadsEot.test.ts +++ b/src/test/testing/common/testingPayloadsEot.test.ts @@ -27,6 +27,7 @@ import { PAYLOAD_SPLIT_ACROSS_CHUNKS_ARRAY, DataWithPayloadChunks, PAYLOAD_SPLIT_MULTI_CHUNK_ARRAY, + PAYLOAD_ONLY_HEADER_MULTI_CHUNK, } from '../testController/payloadTestCases'; import { traceLog } from '../../../client/logging'; @@ -37,6 +38,10 @@ export interface TestCase { } const testCases: Array = [ + { + name: 'header in single chunk edge case', + value: PAYLOAD_ONLY_HEADER_MULTI_CHUNK(FAKE_UUID), + }, { name: 'single payload single chunk', value: PAYLOAD_SINGLE_CHUNK(FAKE_UUID), diff --git a/src/test/testing/testController/payloadTestCases.ts b/src/test/testing/testController/payloadTestCases.ts index 5ddcc0edecf9..40b2113904dd 100644 --- a/src/test/testing/testController/payloadTestCases.ts +++ b/src/test/testing/testController/payloadTestCases.ts @@ -82,6 +82,25 @@ export function PAYLOAD_MULTI_CHUNK(uuid: string): DataWithPayloadChunks { }; } +// more than one payload, split so the first one is only 'Content-Length' to confirm headers +// with null values are ignored +export function PAYLOAD_ONLY_HEADER_MULTI_CHUNK(uuid: string): DataWithPayloadChunks { + const payloadArray: string[] = []; + const result = JSON.stringify(SINGLE_UNITTEST_SUBTEST.result); + + const val = createPayload(uuid, SINGLE_UNITTEST_SUBTEST); + const firstSpaceIndex = val.indexOf(' '); + const payload1 = val.substring(0, firstSpaceIndex); + const payload2 = val.substring(firstSpaceIndex); + payloadArray.push(payload1); + payloadArray.push(payload2); + payloadArray.push(EOT_PAYLOAD); + return { + payloadArray, + data: result, + }; +} + // single payload divided by an arbitrary character and split across payloads export function PAYLOAD_SPLIT_ACROSS_CHUNKS_ARRAY(uuid: string): DataWithPayloadChunks { const payload = createPayload(uuid, SINGLE_PYTEST_PAYLOAD);