mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-09 05:06:04 +00:00
Fix status code
This commit is contained in:
parent
4d26f504f8
commit
b3f75d3c53
|
@ -92,14 +92,17 @@ namespace WelsonJS.Launcher
|
||||||
|
|
||||||
private void ServeResource(HttpListenerContext context, byte[] data, string mimeType = "text/html")
|
private void ServeResource(HttpListenerContext context, byte[] data, string mimeType = "text/html")
|
||||||
{
|
{
|
||||||
|
int statusCode = 200;
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = "text/html".Equals(mimeType, StringComparison.OrdinalIgnoreCase) ?
|
data = "text/html".Equals(mimeType, StringComparison.OrdinalIgnoreCase) ?
|
||||||
Encoding.UTF8.GetBytes("<html><body><h1>Could not find the resource.</h1></body></html>") :
|
Encoding.UTF8.GetBytes("<html><body><h1>Could not find the resource.</h1></body></html>") :
|
||||||
Encoding.UTF8.GetBytes("Could not find the resource.")
|
Encoding.UTF8.GetBytes("Could not find the resource.")
|
||||||
;
|
;
|
||||||
|
statusCode = 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Response.StatusCode = 404;
|
context.Response.StatusCode = statusCode;
|
||||||
context.Response.ContentType = mimeType;
|
context.Response.ContentType = mimeType;
|
||||||
context.Response.ContentLength64 = data.Length;
|
context.Response.ContentLength64 = data.Length;
|
||||||
context.Response.OutputStream.Write(data, 0, data.Length);
|
context.Response.OutputStream.Write(data, 0, data.Length);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user