-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaces.cs
More file actions
114 lines (101 loc) · 3.19 KB
/
Interfaces.cs
File metadata and controls
114 lines (101 loc) · 3.19 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System.Net;
namespace Samicpp.Http;
public interface IHttpSocket
{
IHttpClient Client { get; }
bool IsClosed { get; }
bool IsHttps { get; }
bool HeadSent { get; }
int Status { get; set; }
string StatusMessage { get; set; }
void SetHeader(string name, string value);
void AddHeader(string name, string value);
List<string> DelHeader(string name);
CompressionType Compression { get; set; }
EndPoint? EndPoint { get; }
// ISocket Conn { get; }
}
public interface ISyncHttpSocket : IHttpSocket, IDisposable
{
IHttpClient ReadClient();
WebSocket.WebSocket WebSocket(); // might remove later, HTTP/1.1 only
void Close();
void Close(string text);
void Close(Span<byte> bytes);
void Close(byte[] bytes);
void Close(Stream stream);
void Write(string text);
void Write(Span<byte> bytes);
void Write(byte[] bytes);
// void Write(Stream stream);
}
public interface IAsyncHttpSocket: IHttpSocket, IAsyncDisposable
{
Task<IHttpClient> ReadClientAsync();
Task<WebSocket.WebSocket> WebSocketAsync();
Task CloseAsync();
Task CloseAsync(string text);
Task CloseAsync(Memory<byte> bytes);
Task CloseAsync(byte[] bytes);
Task CloseAsync(Stream stream);
Task WriteAsync(string text);
Task WriteAsync(Memory<byte> bytes);
Task WriteAsync(byte[] bytes);
// Task WriteAsync(Stream stream);
// new IAsyncSocket Conn { get; }
}
public interface IDualHttpSocket : IAsyncHttpSocket, ISyncHttpSocket
{
// new IDualSocket Conn { get; }
}
public interface IHttpClient
{
public bool IsValid { get; }
public Dictionary<string, List<string>> Headers { get; }
public string Host { get; }
public string Method { get; }
public string Path { get; }
public HttpVersion Version { get; }
public string VersionString { get; }
public List<byte> Body { get; }
public bool HeadersComplete { get; }
public bool BodyComplete { get; }
}
public interface ISocket
{
bool CanRead { get; }
bool CanWrite { get; }
bool IsSecure { get; }
}
public interface IAsyncSocket : ISocket, IAsyncDisposable
{
Task FlushAsync();
// ValueTask DisposeAsync();
Task<int> ReadAsync(Memory<byte> bytes);
Task<int> ReadAsync(byte[] bytes, int offset, int size);
Task WriteAsync(Stream stream);
Task WriteAsync(Memory<byte> bytes);
Task WriteAsync(byte[] bytes, int offset, int size);
Task<List<byte>> ReadAllAsync();
Task<byte[]> ReadCertainAsync(int size);
Task<List<byte>> ReadUntilAsync(byte stop);
Task<List<byte>> ReadUntilAsync(byte[] stop);
Task<List<byte>> ReadUntilAsync(params byte[][] stop);
}
public interface ISyncSocket : ISocket, IDisposable
{
void Flush();
void Close();
// void Dispose();
int Read(Span<byte> bytes);
int Read(byte[] bytes, int offset, int size);
void Write(Stream stream);
void Write(Span<byte> bytes);
void Write(byte[] bytes, int offset, int size);
public List<byte> ReadAll();
byte[] ReadCertain(int size);
List<byte> ReadUntil(byte stop);
List<byte> ReadUntil(byte[] stop);
List<byte> ReadUntil(params byte[][] stop);
}
public interface IDualSocket : IAsyncSocket, ISyncSocket { }