-
Notifications
You must be signed in to change notification settings - Fork 0
/
Webbe.Response.cs
50 lines (48 loc) · 1.55 KB
/
Webbe.Response.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections.Generic;
using System.Text;
namespace Teto
{
public partial class Webbe
{
/// <summary>
/// A server's response to an HTTP request.
/// </summary>
public class Response {
/// <summary>
/// The response code (e.g. 200).
/// </summary>
public int Code { get; private set; }
/// <summary>
/// The binary body returned.
/// </summary>
public byte[] Data { get; private set; }
/// <summary>
/// The encoding of this response.
/// </summary>
public Encoding Encoding { get; private set; } = Encoding.UTF8;
/// <summary>
/// The headers received.
/// </summary>
public Dictionary<string, string> Headers { get; private set; }
/// <summary>
/// The binary body as a string.
/// </summary>
public string DataString {
get {
return Encoding.GetString(Data);
}
}
/// <summary>
/// Construct a response.
/// </summary>
/// <param name="code">The response code.</param>
/// <param name="data">The body data.</param>
/// <param name="headers">The headers received.</param>
public Response(int code, byte[] data, Dictionary<string, string> headers) {
Code = code;
Data = data;
Headers = headers;
}
}
}
}