@@ -19,34 +19,12 @@ import { Deferred, createDeferred } from '../../../common/utils/async';
1919import { createReaderPipe , generateRandomPipeName } from '../../../common/pipes/namedPipes' ;
2020import { EXTENSION_ROOT_DIR } from '../../../constants' ;
2121
22- export function fixLogLines ( content : string ) : string {
23- const lines = content . split ( / \r ? \n / g) ;
24- return `${ lines . join ( '\r\n' ) } \r\n` ;
25- }
2622
2723export function fixLogLinesNoTrailing ( content : string ) : string {
2824 const lines = content . split ( / \r ? \n / g) ;
2925 return `${ lines . join ( '\r\n' ) } ` ;
3026}
31- export interface IJSONRPCData {
32- extractedJSON : string ;
33- remainingRawData : string ;
34- }
35-
36- export interface ParsedRPCHeadersAndData {
37- headers : Map < string , string > ;
38- remainingRawData : string ;
39- }
4027
41- export interface ExtractOutput {
42- uuid : string | undefined ;
43- cleanedJsonData : string | undefined ;
44- remainingRawData : string ;
45- }
46-
47- export const JSONRPC_UUID_HEADER = 'Request-uuid' ;
48- export const JSONRPC_CONTENT_LENGTH_HEADER = 'Content-Length' ;
49- export const JSONRPC_CONTENT_TYPE_HEADER = 'Content-Type' ;
5028export const MESSAGE_ON_TESTING_OUTPUT_MOVE =
5129 'Starting now, all test run output will be sent to the Test Result panel,' +
5230 ' while test discovery output will be sent to the "Python" output channel instead of the "Python Test Log" channel.' +
@@ -58,66 +36,6 @@ export function createTestingDeferred(): Deferred<void> {
5836}
5937
6038
61- export function parseJsonRPCHeadersAndData ( rawData : string ) : ParsedRPCHeadersAndData {
62- /**
63- * Parses the provided raw data to extract JSON-RPC specific headers and remaining data.
64- *
65- * This function aims to extract specific JSON-RPC headers (like UUID, content length,
66- * and content type) from the provided raw string data. Headers are expected to be
67- * delimited by newlines and the format should be "key:value". The function stops parsing
68- * once it encounters an empty line, and the rest of the data after this line is treated
69- * as the remaining raw data.
70- *
71- * @param {string } rawData - The raw string containing headers and possibly other data.
72- * @returns {ParsedRPCHeadersAndData } An object containing the parsed headers as a map and the
73- * remaining raw data after the headers.
74- */
75- const lines = rawData . split ( '\n' ) ;
76- let remainingRawData = '' ;
77- const headerMap = new Map < string , string > ( ) ;
78- for ( let i = 0 ; i < lines . length ; i += 1 ) {
79- const line = lines [ i ] ;
80- if ( line === '' ) {
81- remainingRawData = lines . slice ( i + 1 ) . join ( '\n' ) ;
82- break ;
83- }
84- const [ key , value ] = line . split ( ':' ) ;
85- if ( value && value . trim ( ) ) {
86- if ( [ JSONRPC_UUID_HEADER , JSONRPC_CONTENT_LENGTH_HEADER , JSONRPC_CONTENT_TYPE_HEADER ] . includes ( key ) ) {
87- headerMap . set ( key . trim ( ) , value . trim ( ) ) ;
88- }
89- }
90- }
91-
92- return {
93- headers : headerMap ,
94- remainingRawData,
95- } ;
96- }
97-
98- export function ExtractJsonRPCData ( payloadLength : string | undefined , rawData : string ) : IJSONRPCData {
99- /**
100- * Extracts JSON-RPC content based on provided headers and raw data.
101- *
102- * This function uses the `Content-Length` header from the provided headers map
103- * to determine how much of the rawData string represents the actual JSON content.
104- * After extracting the expected content, it also returns any remaining data
105- * that comes after the extracted content as remaining raw data.
106- *
107- * @param {string | undefined } payloadLength - The value of the `Content-Length` header.
108- * @param {string } rawData - The raw string data from which the JSON content will be extracted.
109- *
110- * @returns {IJSONRPCContent } An object containing the extracted JSON content and any remaining raw data.
111- */
112- const length = parseInt ( payloadLength ?? '0' , 10 ) ;
113- const data = rawData . slice ( 0 , length ) ;
114- const remainingRawData = rawData . slice ( length ) ;
115- return {
116- extractedJSON : data ,
117- remainingRawData,
118- } ;
119- }
120-
12139interface ExecutionResultMessage extends Message {
12240 params : ExecutionTestPayload ;
12341}
0 commit comments