Compare commits
No commits in common. "b118c1cd3004e494a2bb1e285e7488903e6356f5" and "ce757177c60996b5b86134d7e8d4a88dedca7e14" have entirely different histories.
b118c1cd30
...
ce757177c6
2 changed files with 16 additions and 12 deletions
|
@ -173,8 +173,6 @@ public record HttpFields
|
|||
}
|
||||
}
|
||||
|
||||
public delegate void FieldCallback(string name, string value);
|
||||
|
||||
public enum ConnectionType
|
||||
{
|
||||
Close,
|
||||
|
|
|
@ -25,23 +25,27 @@ public class SwitchingProtocols : HttpResponse
|
|||
/// </summary>
|
||||
public class HttpResponse
|
||||
{
|
||||
public static HttpResponse OK(HttpContent? content = null) => new HttpResponse(200, "OK", content);
|
||||
public static HttpResponse OK(HttpContent? content) => new HttpResponse(200, "OK", content);
|
||||
|
||||
public static HttpResponse Redirect(string location) => new HttpResponse(301, "Redirect", new HttpFields() { Location = location });
|
||||
|
||||
public static HttpResponse BadRequest(HttpContent? content = null) => new HttpResponse(400, "Bad request", content);
|
||||
public static HttpResponse BadRequest(HttpContent? content) => new HttpResponse(400, "Bad request", content);
|
||||
|
||||
public static HttpResponse NotFound(HttpContent? content = null) => new HttpResponse(404, "Not found", content);
|
||||
public static HttpResponse NotFound(HttpContent? content) => new HttpResponse(404, "Not found", content);
|
||||
|
||||
public static HttpResponse NotAcceptable(HttpContent? content = null) => new HttpResponse(406, "Not acceptable", content);
|
||||
public static HttpResponse NotAcceptable(HttpContent? content) => new HttpResponse(406, "Not acceptable", content);
|
||||
|
||||
public static HttpResponse InternalServerError(HttpContent? content = null) => new HttpResponse(500, "Internal server error", content);
|
||||
|
||||
public static implicit operator HttpResponse(HttpContent value) => OK(value);
|
||||
|
||||
public static implicit operator HttpResponse(HttpContent? value) => value == null ? NotFound(value) : OK(value);
|
||||
public static HttpResponse InternalServerError(string location) => new HttpResponse(500, "Internal server error");
|
||||
|
||||
public static implicit operator HttpResponse(HttpContent value)
|
||||
{
|
||||
return OK(value);
|
||||
}
|
||||
|
||||
public static implicit operator HttpResponse(HttpContent? value)
|
||||
{
|
||||
return value == null ? NotFound(value) : OK(value);
|
||||
}
|
||||
|
||||
public readonly int StatusCode;
|
||||
|
||||
|
@ -111,4 +115,6 @@ public class HttpResponse
|
|||
|
||||
await stream.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void FieldCallback(string name, string value);
|
Loading…
Reference in a new issue