2using System.Collections.Generic;
5using System.Threading.Tasks;
22 private readonly
string userVariable;
23 private readonly
string[] userPrivileges;
34 params
string[] UserPrivileges)
38 this.webServer = WebServer;
39 this.userVariable = UserVariable;
40 this.userPrivileges = UserPrivileges;
67 int i = s.IndexOf(
'/');
69 s = s.Substring(0, i);
72 bool Forbidden =
false;
83 if (Session is
null ||
85 !(v.ValueObject is
IUser User))
91 foreach (
string Privilege
in this.userPrivileges)
93 if (!User.HasPrivilege(Privilege))
116 if (!(Data is
string[][] Records) || !this.HasColumns(Records, 2))
120 if (!(Accept is
null) && !Accept.
IsAcceptable(
"multipart/mixed"))
123 this.Process(Request, Response, Records);
126 private bool HasColumns(
string[][] Records,
int Nr)
128 foreach (
string[] Record
in Records)
130 if (Record.Length != Nr)
141 Uri OrgUri =
new Uri(Request.
Header.
GetURL(
false,
false));
142 List<EmbeddedContent> Items =
new List<EmbeddedContent>();
143 StringBuilder Header =
new StringBuilder();
146 foreach (
string[] Record
in Records)
150 if (!Uri.TryCreate(OrgUri, Record[0], out Uri ItemUri))
153 if (ItemUri.Scheme != OrgUri.Scheme || ItemUri.Authority != OrgUri.Authority)
159 new KeyValuePair<string, string>(
"Retry-After",
"300"));
162 if (!this.webServer.TryGetResource(ItemUri.LocalPath, out
HttpResource Resource, out
string SubPath) ||
168 using (MemoryStream ms =
new MemoryStream())
170 StringBuilder sb =
new StringBuilder();
175 sb.Append(ItemUri.PathAndQuery);
176 sb.AppendLine(
" HTTP/1.1");
181 sb.AppendLine(Host.
Value);
184 if (!(Referer is
null))
186 sb.Append(
"Referer: ");
187 sb.AppendLine(Referer.
Value);
190 sb.Append(
"Accept: ");
191 sb.AppendLine(Record[1]);
204 this.webServer.RequestReceived(Request2, Request.
RemoteEndPoint, Resource, SubPath);
205 await GetMethod.GET(Request2, Response2);
209 byte[] Bin = ms.ToArray();
215 Raw = Encoding.ASCII.GetBytes(Convert.ToBase64String(Bin)),
223 byte[] Bin = Encoding.UTF8.GetBytes(ex.Message);
228 Raw = Encoding.ASCII.GetBytes(Convert.ToBase64String(Bin)),
235 byte[] Bin = Encoding.UTF8.GetBytes(ex.Message);
240 Raw = Encoding.ASCII.GetBytes(Convert.ToBase64String(Bin)),
Represents content embedded in other content.
Represents mixed content, encoded with multipart/mixed
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Base class for all asynchronous HTTP resources. An asynchronous resource responds outside of the meth...
Base class of all HTTP Exceptions.
int StatusCode
HTTP Status Code.
string Value
HTTP Field Value
Represents an HTTP request.
HttpRequestHeader Header
Request header.
string RemoteEndPoint
Remote end-point.
bool HasData
If the request has data.
Variables Session
Contains session states, if the resource requires sessions, or null otherwise.
string LocalEndPoint
Local end-point.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Base class for all HTTP resources.
static string GetSessionId(HttpRequest Request, HttpResponse Response)
Gets the session ID used for a request.
const string HttpSessionID
The Cookie Key for HTTP Session Identifiers: "HttpSessionID"
string ResourceName
Name of resource.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
string ContentType
The Content-Type entity-header field indicates the media type of the entity-body sent to the recipien...
int StatusCode
HTTP Status code.
async Task Return(object Object)
Returns an object to the client. This method can only be called once per response,...
Implements an HTTP server.
The resource identified by the request is only capable of generating response entities which have con...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
Base class for all transfer encodings.
Transfer encoding for internal transfers of content
Task WaitUntilSent(int TimeoutMilliseconds)
Waits for all of the data to be returned.
Module that controls the life cycle of communication.
static bool Stopping
If the system is stopping.
Allows a client to get multiple resources in one call
override bool HandlesSubPaths
If the resource handles sub-paths.
MultiGetResource(string ResourceName, XmppClient Client, HttpServer WebServer, string UserVariable, params string[] UserPrivileges)
Allows a client to get multiple resources in one call
override bool UserSessions
If the resource uses user sessions.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
bool AllowsPOST
If the POST method is allowed.
Maintains information about an item in the roster.
SubscriptionState State
roup Current subscription state.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Contains information about a variable.
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
GET Interface for HTTP resources.
POST Interface for HTTP resources.
Basic interface for a user.
SubscriptionState
State of a presence subscription.
ContentType
DTLS Record content type.