src/vs/base/common/sseParser.ts

245 LOC · 241 covered · 4 uncovered · 56 ranges · 54 concepts · 17 introducers · 46 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileextHostMcp.test|title=ExtHostMcp IAuthMetadata properties should expose readonly properties|occurrence=1, extHostMcp.test|title=ExtHostMcp createAuthMetadata should create IAuthMetadata with fetched server metadata|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.ts ×1 · 3 introduced LOCextHostMcp.ts ×1extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should handle multiple Bearer challenges and use first scope|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return false when scopes are the same|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true and update scopes when WWW-Authenticate header contains new scopes|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return false when scopes are same but in different order|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true when updating from defined scopes to undefined (no scope in header)|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle non-401 status codes in update()|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should ignore non-Bearer schemes|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true when updating from undefined scopes to defined scopes|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.ts ×1 · 1 introduced LOCextHostMcp.ts ×1extHostMcp.ts ×1 · 2 introduced LOCextHostMcp.ts ×1extHostMcp.ts ×1 · 6 introduced LOCextHostMcp.ts ×1extHostMcp.ts ×1 · 4 introduced LOCextHostMcp.ts ×1extHostMcp.ts ×2 · 4 introduced LOCextHostMcp.ts ×2extHostMcp.ts ×1 · 1 introduced LOCextHostMcp.ts ×1extHostMcp.test|title=ExtHostMcp createAuthMetadata should fall back to default metadata when server metadata fetch fails|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.ts ×4 · 6 introduced LOCextHostMcp.ts ×4extHostMcp.test|title=ExtHostMcp createAuthMetadata should use scopes from WWW-Authenticate header when resource metadata has none|occurrence=1, extHostMcp.test|title=ExtHostMcp createAuthMetadata should use scopes from WWW-Authenticate header even when resource metadata has scopes_supported|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.ts ×1 · 2 introduced LOCextHostMcp.ts ×1extHostMcp.ts ×1 · 6 introduced LOCextHostMcp.ts ×1extHostMcp.ts ×4 · 13 introduced LOCextHostMcp.ts ×4extHostMcpNode.ts ×8 · 45 introduced LOCextHostMcpNode.ts ×8extHostMcp.test|title=ExtHostMcp createAuthMetadata should pass launch headers when fetching metadata from same origin|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.ts ×5 · 25 introduced LOCextHostMcp.ts ×5extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle invalid JSON in resource metadata response|occurrence=1 · 0 introduced LOCextHostMcp.test|title=Ex…extHostMcp.ts ×3 · 23 introduced LOCextHostMcp.ts ×3extHostMcp.ts ×1 · 2 introduced LOCextHostMcp.ts ×1extHostMcp.ts ×8 · 60 introduced LOCextHostMcp.ts ×8extHostMcp.ts ×43 · 874 introduced LOCextHostMcp.ts ×43sseParser.test|title=SSEParser handles events with ID|occurrence=1 · 0 introduced LOCsseParser.test|title=SSE…sseParser.test|title=SSEParser supports spec example|occurrence=1 · 0 introduced LOCsseParser.test|title=SSE…sseParser.test|title=SSEParser handles fields with space after colon|occurrence=1 · 0 introduced LOCsseParser.test|title=SSE…sseParser.ts ×1 · 2 introduced LOCsseParser.ts ×1sseParser.ts ×1 · 2 introduced LOCsseParser.ts ×1sseParser.ts ×2 · 4 introduced LOCsseParser.ts ×2sseParser.ts ×1 · 2 introduced LOCsseParser.ts ×1sseParser.ts ×3 · 5 introduced LOCsseParser.ts ×3sseParser.ts ×1 · 3 introduced LOCsseParser.ts ×1sseParser.ts ×3 · 5 introduced LOCsseParser.ts ×3sseParser.test|title=SSEParser ignores comments|occurrence=1 · 0 introduced LOCsseParser.test|title=SSE…sseParser.ts ×2 · 3 introduced LOCsseParser.ts ×2sseParser.test|title=SSEParser handles events with explicit event type|occurrence=1, sseParser.test|title=SSEParser handles events with explicit event type (CRLF)|occurrence=1 · 0 introduced LOCsseParser.test|title=SSE…sseParser.ts ×1 · 2 introduced LOCsseParser.ts ×1sseParser.test|title=SSEParser resets correctly|occurrence=1, sseParser.test|title=SSEParser handles basic events|occurrence=1, +4 · 0 introduced LOCsseParser.test|title=SSE…sseParser.ts ×3 · 4 introduced LOCsseParser.ts ×3sseParser.test|title=SSEParser handles empty data with blank line|occurrence=1 · 0 introduced LOCsseParser.test|title=SSE…sseParser.ts ×1 · 4 introduced LOCsseParser.ts ×1sseParser.ts ×5 · 26 introduced LOCsseParser.ts ×5sseParser.ts ×1 · 2 introduced LOCsseParser.ts ×1sseParser.ts ×1 · 2 introduced LOCsseParser.ts ×1sseParser.ts ×2 · 7 introduced LOCsseParser.ts ×2sseParser.ts ×19 · 70 introduced LOCsseParser.ts ×19sseParser.ts ×9 · 98 introduced LOCsseParser.ts ×9sseParser.test|title=SSEParser handles basic events|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles basic events|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles different line endings (CR)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles different line endings (CR)|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles different line endings (CRLF)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles different line endings (CRLF)|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles different line endings (LF)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles different line endings (LF)|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles empty data with blank line|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles empty data with blank line|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles events with ID|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles events with ID|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles events with explicit event type (CRLF)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles events with explicit event type (CRLF)|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles events with explicit event type|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles events with explicit event type|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles events with multiple data fields|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles events with multiple data fields|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles fields with no value|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles fields with no value|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles fields with space after colon|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles fields with space after colon|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles invalid retry field|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles invalid retry field|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser handles retry field|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles retry field|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser ignores comments|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser ignores comments|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser ignores events with no data after blank line|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser ignores events with no data after blank line|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser ignores fields with NULL character in ID|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser ignores fields with NULL character in ID|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser resets correctly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser resets correctly|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser stream processing chunks|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser stream processing chunks|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser supports chunked data|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser supports chunked data|occurrence=1sseParser.test|title=SSE…sseParser.test|title=SSEParser supports spec example|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser supports spec example|occurrence=1sseParser.test|title=SSE…extHostMcp.test|title=ExtHostMcp IAuthMetadata properties should allow undefined scopes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata properties should allow undefined scopes|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata properties should expose readonly properties|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata properties should expose readonly properties|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should handle multiple Bearer challenges and use first scope|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should handle multiple Bearer challenges and use first scope|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should ignore non-Bearer schemes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should ignore non-Bearer schemes|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return false when no WWW-Authenticate header and scopes are already undefined|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return false when no WWW-Authenticate header and scopes are already undefined|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return false when scopes are same but in different order|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return false when scopes are same but in different order|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return false when scopes are the same|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return false when scopes are the same|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true and update scopes when WWW-Authenticate header contains new scopes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true and update scopes when WWW-Authenticate header contains new scopes|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true when updating from defined scopes to undefined (no scope in header)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true when updating from defined scopes to undefined (no scope in header)|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true when updating from undefined scopes to defined scopes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp IAuthMetadata update() should return true when updating from undefined scopes to defined scopes|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should create IAuthMetadata with fetched server metadata|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should create IAuthMetadata with fetched server metadata|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should fall back to default metadata when server metadata fetch fails|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should fall back to default metadata when server metadata fetch fails|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle empty scope string in WWW-Authenticate header|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle empty scope string in WWW-Authenticate header|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle invalid JSON in resource metadata response|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle invalid JSON in resource metadata response|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle malformed WWW-Authenticate header gracefully|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle malformed WWW-Authenticate header gracefully|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle non-401 status codes in update()|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should handle non-401 status codes in update()|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should pass launch headers when fetching metadata from same origin|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should pass launch headers when fetching metadata from same origin|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should use resource_metadata challenge URL from WWW-Authenticate header|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should use resource_metadata challenge URL from WWW-Authenticate header|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should use scopes from WWW-Authenticate header even when resource metadata has scopes_supported|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should use scopes from WWW-Authenticate header even when resource metadata has scopes_supported|occurrence=1extHostMcp.test|title=Ex…extHostMcp.test|title=ExtHostMcp createAuthMetadata should use scopes from WWW-Authenticate header when resource metadata has none|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostMcp.test|title=ExtHostMcp createAuthMetadata should use scopes from WWW-Authenticate header when resource metadata has none|occurrence=1extHostMcp.test|title=Ex…extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg does not add stray ^ to argument values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/node/extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg does not add stray ^ to argument values|occurrence=1extHostMcpNode.test|titl…extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg doubles embedded double quotes (cmd.exe convention)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/node/extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg doubles embedded double quotes (cmd.exe convention)|occurrence=1extHostMcpNode.test|titl…extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg neutralizes cmd.exe metacharacters inside quotes (CVE-2024-27980)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/node/extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg neutralizes cmd.exe metacharacters inside quotes (CVE-2024-27980)|occurrence=1extHostMcpNode.test|titl…extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg preserves paths with parentheses without injecting ^|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/node/extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg preserves paths with parentheses without injecting ^|occurrence=1extHostMcpNode.test|titl…extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg preserves paths with spaces|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/node/extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg preserves paths with spaces|occurrence=1extHostMcpNode.test|titl…extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg wraps simple values in double quotes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/node/extHostMcpNode.test|title=extHostMcpNode - escapeCmdArg wraps simple values in double quotes|occurrence=1extHostMcpNode.test|titl…Focused file · src/vs/base/common/sseParser.ts · 245 LOCcommon/sseParser.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- sseParser.ts ×9
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > /**
7 > * Parser for Server-Sent Events (SSE) streams according to the HTML specification.
8 > * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation
9 > */
10 >
11 > /**
12 > * Represents an event dispatched from an SSE stream.
13 > */
14 > export interface ISSEEvent {
15 > /**
16 > * The event type. If not specified, the type is "message".
17 > */
18 > type: string;
19 >
20 > /**
21 > * The event data.
22 > */
23 > data: string;
24 >
25 > /**
26 > * The last event ID, used for reconnection.
27 > */
28 > id?: string;
29 >
30 > /**
31 > * Reconnection time in milliseconds.
32 > */
33 > retry?: number;
34 > }
35 >
36 > /**
37 > * Callback function type for event dispatch.
38 > */
39 > export type SSEEventHandler = (event: ISSEEvent) => void;
40 >
41 > const enum Chr {
42 > CR = 13, // '\r'
43 > LF = 10, // '\n'
44 > COLON = 58, // ':'
45 > SPACE = 32, // ' '
46 > }
47 >
48 > /**
49 > * Parser for Server-Sent Events (SSE) streams.
50 > */
51 > export class SSEParser {
52 > private dataBuffer = '';
53 > private eventTypeBuffer = '';
54 > private currentEventId?: string;
55 > private lastEventIdBuffer?: string;
56 > private reconnectionTime?: number;
57 > private buffer: Uint8Array[] = [];
58 > private endedOnCR = false;
59 > private readonly onEventHandler: SSEEventHandler;
60 > private readonly decoder: TextDecoder;
61 > /**
62 > * Creates a new SSE parser.
63 > * @param onEvent The callback to invoke when an event is dispatched.
64 > */
65 > constructor(onEvent: SSEEventHandler) {
66 > this.onEventHandler = onEvent; sseParser.ts ×19
67 > this.decoder = new TextDecoder('utf-8');
68 > }
70 > /**
71 > * Gets the last event ID received by this parser.
72 > */
73 > public getLastEventId(): string | undefined {
74 > return this.lastEventIdBuffer; sseParser.ts ×1
75 > }
76 > /** sseParser.ts ×9
77 > * Gets the reconnection time in milliseconds, if one was specified by the server.
78 > */
79 > public getReconnectionTime(): number | undefined {
80 > return this.reconnectionTime; sseParser.ts ×3
81 > }
83 > /**
84 > * Feeds a chunk of the SSE stream to the parser.
85 > * @param chunk The chunk to parse as a Uint8Array of UTF-8 encoded data.
86 > */
87 > public feed(chunk: Uint8Array): void {
88 > if (chunk.length === 0) { sseParser.ts ×19
89 return;
90 }
92 > let offset = 0;
93 >
94 > // If the data stream was bifurcated between a CR and LF, avoid processing the CR as an extra newline
95 > if (this.endedOnCR && chunk[0] === Chr.LF) {
96 > offset++; sseParser.ts ×1
97 > }
98 > this.endedOnCR = false; sseParser.ts ×19
99 >
100 > // Process complete lines from the buffer
101 > while (offset < chunk.length) {
102 > const indexCR = chunk.indexOf(Chr.CR, offset);
103 > const indexLF = chunk.indexOf(Chr.LF, offset);
104 > const index = indexCR === -1 ? indexLF : (indexLF === -1 ? indexCR : Math.min(indexCR, indexLF));
105 > if (index === -1) {
106 > break; sseParser.ts ×3
107 > }
109 > let str = '';
110 > for (const buf of this.buffer) {
111 > str += this.decoder.decode(buf, { stream: true }); sseParser.ts ×3
112 > }
113 > str += this.decoder.decode(chunk.subarray(offset, index)); sseParser.ts ×19
114 > this.processLine(str);
115 >
116 > this.buffer.length = 0;
117 > offset = index + (chunk[index] === Chr.CR && chunk[index + 1] === Chr.LF ? 2 : 1);
118 > }
119 >
120 >
121 > if (offset < chunk.length) {
122 > this.buffer.push(chunk.subarray(offset)); sseParser.ts ×3
123 > } else { sseParser.ts ×19
124 > this.endedOnCR = chunk[chunk.length - 1] === Chr.CR;
125 > }
126 > }
127 > /** sseParser.ts ×9
128 > * Processes a single line from the SSE stream.
129 > */
130 > private processLine(line: string): void {
131 > if (!line.length) { sseParser.ts ×19
132 > this.dispatchEvent();
133 > return;
134 > }
135 >
136 > if (line.startsWith(':')) {
137 > return; sseParser.ts ×1
138 > }
140 > // Parse the field name and value
141 > let field: string;
142 > let value: string;
143 >
144 > const colonIndex = line.indexOf(':');
145 > if (colonIndex === -1) {
146 > // Line with no colon - the entire line is the field name, value is empty sseParser.ts ×1
147 > field = line;
148 > value = '';
149 > } else { sseParser.ts ×19
150 > // Line with a colon - split into field name and value sseParser.ts ×2
151 > field = line.substring(0, colonIndex);
152 > value = line.substring(colonIndex + 1);
153 >
154 > // If value starts with a space, remove it
155 > if (value.startsWith(' ')) {
156 > value = value.substring(1); sseParser.ts ×1
157 > }
160 > this.processField(field, value);
161 > }
162 > /** sseParser.ts ×9
163 > * Processes a field with the given name and value.
164 > */
165 > private processField(field: string, value: string): void {
166 > switch (field) { sseParser.ts ×19
167 > case 'event':
168 > this.eventTypeBuffer = value; sseParser.ts ×1
169 > break;
171 > case 'data':
172 > // Append the value to the data buffer, followed by a newline sseParser.ts ×5
173 > this.dataBuffer += value;
174 > this.dataBuffer += '\n';
175 > break;
177 > case 'id':
178 > // If the field value doesn't contain NULL, set the last event ID buffer sseParser.ts ×3
179 > if (!value.includes('\0')) {
180 > this.currentEventId = this.lastEventIdBuffer = value; sseParser.ts ×2
181 > } else { sseParser.ts ×3
182 > this.currentEventId = undefined; sseParser.ts ×1
183 > }
184 > break; sseParser.ts ×3
186 > case 'retry':
187 > // If the field value consists only of ASCII digits, set the reconnection time sseParser.ts ×3
188 > if (/^\d+$/.test(value)) {
189 > this.reconnectionTime = parseInt(value, 10); sseParser.ts ×2
190 > }
191 > break; sseParser.ts ×3
193 > // Ignore any other fields
194 > }
195 > }
196 > /** sseParser.ts ×9
197 > * Dispatches the event based on the current buffer states.
198 > */
199 > private dispatchEvent(): void {
200 > // If the data buffer is empty, reset the buffers and return sseParser.ts ×19
201 > if (this.dataBuffer === '') {
202 > this.dataBuffer = ''; sseParser.ts ×1
203 > this.eventTypeBuffer = '';
204 > return;
205 > }
207 > // If the data buffer's last character is a newline, remove it
208 > if (this.dataBuffer.endsWith('\n')) {
209 > this.dataBuffer = this.dataBuffer.substring(0, this.dataBuffer.length - 1);
210 > }
211 >
212 > // Create and dispatch the event
213 > const event: ISSEEvent = {
214 > type: this.eventTypeBuffer || 'message',
215 > data: this.dataBuffer, sseParser.ts ×19
216 > };
217 >
218 > // Add optional fields if they exist
219 > if (this.currentEventId !== undefined) {
220 > event.id = this.currentEventId; sseParser.ts ×2
221 > }
223 > if (this.reconnectionTime !== undefined) {
224 > event.retry = this.reconnectionTime; sseParser.ts ×2
225 > }
227 > // Dispatch the event
228 > this.onEventHandler(event);
229 >
230 > // Reset the data and event type buffers
231 > this.reset();
234 > /**
235 > * Resets the parser state.
236 > */
237 > public reset(): void {
238 > this.dataBuffer = ''; sseParser.ts ×5
239 > this.eventTypeBuffer = '';
240 > this.currentEventId = undefined;
241 > // Note: lastEventIdBuffer is not reset as it's used for reconnection
242 > }
244
245