File tree Expand file tree Collapse file tree 2 files changed +10
-19
lines changed
extensions/gitpod-shared/src Expand file tree Collapse file tree 2 files changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -1044,7 +1044,7 @@ async function updateIpcHookCli(context: GitpodExtensionContext): Promise<void>
10441044 hostname : 'localhost' ,
10451045 port : context . devMode ? 9888 /* From code-web.js */ : context . info . getIdePort ( ) ,
10461046 protocol : 'http:' ,
1047- path : ' /cli' ,
1047+ path : ` /cli/ipcHookCli/ ${ encodeURIComponent ( context . ipcHookCli ! ) } ` ,
10481048 method : vscode . window . state . focused ? 'PUT' : 'DELETE'
10491049 } , res => {
10501050 const chunks : string [ ] = [ ] ;
@@ -1060,7 +1060,6 @@ async function updateIpcHookCli(context: GitpodExtensionContext): Promise<void>
10601060 } ) ;
10611061 } ) ;
10621062 req . on ( 'error' , err => reject ( err ) ) ;
1063- req . write ( context . ipcHookCli ) ;
10641063 req . end ( ) ;
10651064 } ) ;
10661065 } catch ( e ) {
Original file line number Diff line number Diff line change @@ -52,32 +52,24 @@ function setActiveCliIpcHook(cliIpcHook: string): void {
5252}
5353
5454export function handleGitpodCLIRequest ( pathname : string , req : http . IncomingMessage , res : http . ServerResponse ) {
55- if ( pathname === '/cli' ) {
55+ if ( pathname . startsWith ( '/cli' ) ) {
5656 if ( req . method === 'GET' ) {
5757 res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
5858 res . end ( activeCliIpcHook ) ;
5959 return true ;
6060 }
6161 if ( req . method === 'DELETE' ) {
62- let cliIpcHook = '' ;
63- req . setEncoding ( 'utf8' ) ;
64- req . on ( 'data' , ( chunk : string ) => cliIpcHook += chunk ) ;
65- req . on ( 'end' , ( ) => {
66- deleteActiveCliIpcHook ( cliIpcHook ) ;
67- res . writeHead ( 200 ) ;
68- res . end ( ) ;
69- } ) ;
62+ const cliIpcHook = decodeURIComponent ( pathname . substring ( '/cli/ipcHookCli/' . length ) ) ;
63+ deleteActiveCliIpcHook ( cliIpcHook ) ;
64+ res . writeHead ( 200 ) ;
65+ res . end ( ) ;
7066 return true ;
7167 }
7268 if ( req . method === 'PUT' ) {
73- let cliIpcHook = '' ;
74- req . setEncoding ( 'utf8' ) ;
75- req . on ( 'data' , ( chunk : string ) => cliIpcHook += chunk ) ;
76- req . on ( 'end' , ( ) => {
77- setActiveCliIpcHook ( cliIpcHook ) ;
78- res . writeHead ( 200 ) ;
79- res . end ( ) ;
80- } ) ;
69+ const cliIpcHook = decodeURIComponent ( pathname . substring ( '/cli/ipcHookCli/' . length ) ) ;
70+ setActiveCliIpcHook ( cliIpcHook ) ;
71+ res . writeHead ( 200 ) ;
72+ res . end ( ) ;
8173 return true ;
8274 }
8375 if ( req . method === 'POST' ) {
You can’t perform that action at this time.
0 commit comments