-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpRequest.cs
33 lines (27 loc) · 947 Bytes
/
HttpRequest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace Httpd.Impl;
public class HttpRequest : IDisposable
{
public required HttpMethod Method { get; init; }
public required string Version { get; init; }
public required string RawUrl { get; init; }
public required string LocalPath { get; init; }
public required string RawQueryString { get; init; }
public required IReadOnlyDictionary<string, string> Headers { get; init; }
public required IReadOnlyDictionary<string, string> QueryString { get; init; }
public Stream InputStream { get; private set; }
public HttpRequest(Stream stream)
=> InputStream = stream;
public void Dispose()
=> InputStream = default;
public string ContentType
=> Headers["content-type"];
public long ContentLength
{
get
{
if (Headers.TryGetValue("content-length", out var s))
return long.Parse(s);
return 0L;
}
}
}