mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-09 13:16:05 +00:00
Update ResourceServer.cs
This commit is contained in:
parent
6722704859
commit
1f2a1e79b7
|
@ -108,10 +108,13 @@ namespace WelsonJS.Launcher
|
||||||
{
|
{
|
||||||
int statusCode = 200;
|
int statusCode = 200;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
List<string> executables = _executablesCollector.GetExecutables();
|
List<string> executables = _executablesCollector.GetExecutables();
|
||||||
|
|
||||||
CompletionItem[] completionItems = executables
|
CompletionItem[] completionItems = executables
|
||||||
.Where(exec => exec.IndexOf(word, 0, StringComparison.OrdinalIgnoreCase) > -1)
|
.Where(exec => exec.IndexOf(word, 0, StringComparison.OrdinalIgnoreCase) > -1)
|
||||||
|
.Take(100) // Limit results to prevent excessive response sizes
|
||||||
.Select(exec => new CompletionItem
|
.Select(exec => new CompletionItem
|
||||||
{
|
{
|
||||||
Label = Path.GetFileName(exec),
|
Label = Path.GetFileName(exec),
|
||||||
|
@ -143,6 +146,21 @@ namespace WelsonJS.Launcher
|
||||||
outputStream.Write(data, 0, data.Length);
|
outputStream.Write(data, 0, data.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
byte[] errorData = Encoding.UTF8.GetBytes(
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
|
||||||
|
$"<error>Failed to process completion request. {ex.Message}</error>"
|
||||||
|
);
|
||||||
|
context.Response.StatusCode = 500;
|
||||||
|
context.Response.ContentType = "application/xml";
|
||||||
|
context.Response.ContentLength64 = errorData.Length;
|
||||||
|
using (Stream outputStream = context.Response.OutputStream)
|
||||||
|
{
|
||||||
|
outputStream.Write(errorData, 0, errorData.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ServeResource(HttpListenerContext context, byte[] data, string mimeType = "text/html")
|
private void ServeResource(HttpListenerContext context, byte[] data, string mimeType = "text/html")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user