Files
WebServer.Test/WebServer/HttpResponse.cs
Kaveman b21a1caabc Test Project Created
+ Implemented Request Processing (Cache => Regex Events => Razor Pages => Static Content)
 + Rendering based on domain works
 - Areas are not implemented
 + Content Type Map now defines `.cshtml` files and default mime type was changed to "text/plain"
 + GetStaticFile no longer returns private templates/layouts (used to be able to view those in plain text by requesting with a fully qualified path)
I will make more concise tests in a bit (I was not pushing to git properly, so have to make big commits for the time being)
2024-08-15 01:10:06 -07:00

34 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using WebServer.Utils;
namespace WebServer {
public class HttpResponse {
public HttpStatusCode StatusCode = HttpStatusCode.NoContent;
public bool IsSuccessStatusCode => (int)StatusCode >= 200 && (int)StatusCode <= 299;
public string ContentType = MimeTypeMap.GetMimeType(".txt");
public byte[] Content = Array.Empty<byte>();
public string ContentString {
get => Encoding.UTF8.GetString(Content);
set => Content = Encoding.UTF8.GetBytes(value);
}
public Dictionary<string, string?> Headers = new Dictionary<string, string?>();
public HttpResponse() { }
public HttpResponse(HttpStatusCode statusCode, byte[] content, string contentType = "text/plain") {
StatusCode = statusCode;
Content = content;
ContentType = contentType;
}
public HttpResponse(HttpStatusCode statusCode, string content, string contentType = "text/plain") {
StatusCode = statusCode;
ContentString = content;
ContentType = contentType;
}
}
}