File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ class MainApp {
8585 setExclusions ( exclusions . join ( ',' ) ) ;
8686 }
8787
88- const r = await fetch ( "/bootstrap.flag" , {
88+ const r = await fetch ( "/rewrite= bootstrap.flag" , {
8989 method : 'POST' ,
9090 body : "ok"
9191 } ) ;
@@ -96,15 +96,19 @@ class MainApp {
9696 if ( resultString . length == 0 ) break ;
9797 document . getElementById ( "out" ) . innerHTML += resultString ;
9898 console . log ( resultString ) ;
99+ await fetch ( "/log=bench-log.txt" , {
100+ method : 'POST' ,
101+ body : resultString
102+ } ) ;
99103 }
100104
101105 document . getElementById ( "out" ) . innerHTML += "Finished" ;
102- const r1 = await fetch ( "/results.json" , {
106+ const r1 = await fetch ( "/rewrite= results.json" , {
103107 method : 'POST' ,
104108 body : getFullJsonResults ( )
105109 } ) ;
106110 console . log ( "post request complete, response: " , r1 ) ;
107- const r2 = await fetch ( "/results.html" , {
111+ const r2 = await fetch ( "/rewrite= results.html" , {
108112 method : 'POST' ,
109113 body : document . getElementById ( "out" ) . innerHTML
110114 } ) ;
Original file line number Diff line number Diff line change @@ -191,11 +191,32 @@ private async void ReceivePostAsync(HttpListenerContext context)
191191 if ( contentType != null && contentType . StartsWith ( "text/plain" ) && path . StartsWith ( "/" ) )
192192 {
193193 path = path . Substring ( 1 ) ;
194+ var split = path . Split ( '=' ) ;
195+ string cmd ;
196+ if ( split . Length > 1 )
197+ {
198+ cmd = split [ 0 ] ;
199+ path = split [ 1 ] ;
200+ } else
201+ cmd = "rewrite" ;
202+
194203 if ( Verbose )
195- Console . WriteLine ( $ " writting POST stream to '{ path } ' file ") ;
204+ Console . WriteLine ( $ " POST cmd: { cmd } path: '{ path } '") ;
196205
197206 var content = await new StreamReader ( context . Request . InputStream ) . ReadToEndAsync ( ) . ConfigureAwait ( false ) ;
198- await File . WriteAllTextAsync ( path , content ) . ConfigureAwait ( false ) ;
207+
208+ switch ( cmd ) {
209+ case "rewrite" :
210+ await File . WriteAllTextAsync ( path , content ) . ConfigureAwait ( false ) ;
211+ break ;
212+ case "log" :
213+ await File . AppendAllTextAsync ( path , content + "\n " ) . ConfigureAwait ( false ) ;
214+ Console . WriteLine ( $ " log: { content } ") ;
215+ break ;
216+ default :
217+ Console . WriteLine ( $ " unknown command: { cmd } ") ;
218+ break ;
219+ }
199220 }
200221 else
201222 return ;
You can’t perform that action at this time.
0 commit comments