forked from stevenh/HttpServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IHttpListener.cs
83 lines (71 loc) · 2.39 KB
/
IHttpListener.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Net;
using System.Net.Sockets;
using HttpServer.Logging;
namespace HttpServer
{
/// <summary>
/// Http listener
/// </summary>
public interface IHttpListener
{
/// <summary>
/// Gets listener address.
/// </summary>
IPAddress Address { get; }
/// <summary>
/// Gets if listener is secure.
/// </summary>
bool IsSecure { get; }
/// <summary>
/// Gets if listener have been started.
/// </summary>
bool IsStarted { get; }
/// <summary>
/// Gets or sets logger.
/// </summary>
ILogger Logger { get; set; }
/// <summary>
/// Gets listening port.
/// </summary>
int Port { get; }
/// <summary>
/// Gets the maximum content size.
/// </summary>
/// <value>The content length limit.</value>
/// <remarks>
/// Used when responding to 100-continue.
/// </remarks>
int ContentLengthLimit { get; set; }
/// <summary>
/// Start listener.
/// </summary>
/// <param name="backLog">Number of pending accepts.</param>
/// <remarks>
/// Make sure that you are subscribing on <see cref="RequestReceived"/> first.
/// </remarks>
/// <exception cref="InvalidOperationException">Listener have already been started.</exception>
/// <exception cref="SocketException">Failed to start socket.</exception>
/// <exception cref="ArgumentOutOfRangeException">Invalid port number.</exception>
void Start(int backLog);
/// <summary>
/// Stop listener.
/// </summary>
void Stop();
/// <summary>
/// A new request have been received.
/// </summary>
event EventHandler<RequestEventArgs> RequestReceived;
/// <summary>
/// Can be used to reject certain clients.
/// </summary>
event EventHandler<SocketFilterEventArgs> SocketAccepted;
/// <summary>
/// A HTTP exception have been thrown.
/// </summary>
/// <remarks>
/// Fill the body with a user friendly error page, or redirect to somewhere else.
/// </remarks>
event EventHandler<ErrorPageEventArgs> ErrorPageRequested;
}
}