Compare commits

...

2 commits

Author SHA1 Message Date
uwaa
8cd6f8eb17 http: nitpick 2024-12-09 22:30:43 +00:00
uwaa
1f3a62a7a8 http: add Forbidden 2024-12-09 22:30:37 +00:00
2 changed files with 3 additions and 4 deletions

View file

@ -31,6 +31,8 @@ public class HttpResponse
public static HttpResponse BadRequest(HttpContent? content = null) => new HttpResponse(400, "Bad request", content);
public static HttpResponse Forbidden(HttpContent? content = null) => new HttpResponse(403, "Forbidden", content);
public static HttpResponse NotFound(HttpContent? content = null) => new HttpResponse(404, "Not found", content);
public static HttpResponse NotAcceptable(HttpContent? content = null) => new HttpResponse(406, "Not acceptable", content);

View file

@ -90,10 +90,7 @@ class MIMETypeConverter : JsonConverter<MIMEType>
public override MIMEType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string? str = reader.GetString();
if (str == null)
throw new JsonException("Cannot read MIME type");
string? str = reader.GetString() ?? throw new JsonException("Cannot read MIME type");
return new MIMEType(str);
}